@antv/g 3.5.0-beta.4 → 5.0.2

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 (748) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +0 -546
  3. package/dist/index.umd.js +15 -0
  4. package/es/AbstractRenderer.d.ts +26 -0
  5. package/es/AbstractRenderer.js +42 -0
  6. package/es/Canvas.d.ts +97 -0
  7. package/es/Canvas.js +406 -0
  8. package/es/DisplayObjectPool.d.ts +7 -0
  9. package/es/DisplayObjectPool.js +27 -0
  10. package/es/camera/Camera.d.ts +279 -0
  11. package/es/camera/Camera.js +973 -0
  12. package/es/camera/Landmark.d.ts +28 -0
  13. package/es/camera/Landmark.js +68 -0
  14. package/es/camera/index.d.ts +2 -0
  15. package/es/camera/index.js +2 -0
  16. package/es/canvas-module.d.ts +1 -0
  17. package/es/canvas-module.js +33 -0
  18. package/es/components/Cullable.d.ts +14 -0
  19. package/es/components/Cullable.js +28 -0
  20. package/es/components/Geometry.d.ts +12 -0
  21. package/es/components/Geometry.js +10 -0
  22. package/es/components/Renderable.d.ts +24 -0
  23. package/es/components/Renderable.js +18 -0
  24. package/es/components/Sortable.d.ts +16 -0
  25. package/es/components/Sortable.js +15 -0
  26. package/es/components/Transform.d.ts +29 -0
  27. package/es/components/Transform.js +65 -0
  28. package/es/components/index.d.ts +5 -0
  29. package/es/components/index.js +5 -0
  30. package/es/display-objects/Circle.d.ts +12 -0
  31. package/es/display-objects/Circle.js +26 -0
  32. package/es/display-objects/CustomElement.d.ts +22 -0
  33. package/es/display-objects/CustomElement.js +79 -0
  34. package/es/display-objects/DisplayObject.d.ts +259 -0
  35. package/es/display-objects/DisplayObject.js +855 -0
  36. package/es/display-objects/Ellipse.d.ts +14 -0
  37. package/es/display-objects/Ellipse.js +27 -0
  38. package/es/display-objects/Group.d.ts +6 -0
  39. package/es/display-objects/Group.js +27 -0
  40. package/es/display-objects/HTML.d.ts +36 -0
  41. package/es/display-objects/HTML.js +93 -0
  42. package/es/display-objects/Image.d.ts +16 -0
  43. package/es/display-objects/Image.js +25 -0
  44. package/es/display-objects/Line.d.ts +23 -0
  45. package/es/display-objects/Line.js +56 -0
  46. package/es/display-objects/Path.d.ts +47 -0
  47. package/es/display-objects/Path.js +132 -0
  48. package/es/display-objects/Polygon.d.ts +12 -0
  49. package/es/display-objects/Polygon.js +25 -0
  50. package/es/display-objects/Polyline.d.ts +23 -0
  51. package/es/display-objects/Polyline.js +75 -0
  52. package/es/display-objects/Rect.d.ts +16 -0
  53. package/es/display-objects/Rect.js +26 -0
  54. package/es/display-objects/Text.d.ts +65 -0
  55. package/es/display-objects/Text.js +61 -0
  56. package/es/display-objects/index.d.ts +13 -0
  57. package/es/display-objects/index.js +13 -0
  58. package/es/dom/Animation.d.ts +132 -0
  59. package/es/dom/Animation.js +503 -0
  60. package/es/dom/AnimationEffectTiming.d.ts +58 -0
  61. package/es/dom/AnimationEffectTiming.js +68 -0
  62. package/es/dom/AnimationEvent.d.ts +11 -0
  63. package/es/dom/AnimationEvent.js +34 -0
  64. package/es/dom/AnimationTimeline.d.ts +37 -0
  65. package/es/dom/AnimationTimeline.js +218 -0
  66. package/es/dom/CustomElementRegistry.d.ts +15 -0
  67. package/es/dom/CustomElementRegistry.js +42 -0
  68. package/es/dom/CustomEvent.d.ts +16 -0
  69. package/es/dom/CustomEvent.js +35 -0
  70. package/es/dom/Document.d.ts +59 -0
  71. package/es/dom/Document.js +174 -0
  72. package/es/dom/Element.d.ts +149 -0
  73. package/es/dom/Element.js +491 -0
  74. package/es/dom/EventTarget.d.ts +40 -0
  75. package/es/dom/EventTarget.js +156 -0
  76. package/es/dom/FederatedEvent.d.ts +146 -0
  77. package/es/dom/FederatedEvent.js +232 -0
  78. package/es/dom/FederatedMouseEvent.d.ts +52 -0
  79. package/es/dom/FederatedMouseEvent.js +124 -0
  80. package/es/dom/FederatedPointerEvent.d.ts +69 -0
  81. package/es/dom/FederatedPointerEvent.js +53 -0
  82. package/es/dom/FederatedWheelEvent.d.ts +20 -0
  83. package/es/dom/FederatedWheelEvent.js +27 -0
  84. package/es/dom/KeyframeEffect.d.ts +47 -0
  85. package/es/dom/KeyframeEffect.js +174 -0
  86. package/es/dom/KeyframeList.d.ts +2 -0
  87. package/es/dom/KeyframeList.js +176 -0
  88. package/es/dom/Node.d.ts +106 -0
  89. package/es/dom/Node.js +220 -0
  90. package/es/dom/index.d.ts +17 -0
  91. package/es/dom/index.js +17 -0
  92. package/es/dom/interfaces.d.ts +324 -0
  93. package/es/dom/interfaces.js +32 -0
  94. package/es/global-module.d.ts +2 -0
  95. package/es/global-module.js +173 -0
  96. package/es/index.d.ts +15 -0
  97. package/es/index.js +18 -0
  98. package/es/plugins/CullingPlugin.d.ts +19 -0
  99. package/es/plugins/CullingPlugin.js +79 -0
  100. package/es/plugins/DirtyCheckPlugin.d.ts +10 -0
  101. package/es/plugins/DirtyCheckPlugin.js +52 -0
  102. package/es/plugins/EventPlugin.d.ts +27 -0
  103. package/es/plugins/EventPlugin.js +288 -0
  104. package/es/plugins/FrustumCullingStrategy.d.ts +20 -0
  105. package/es/plugins/FrustumCullingStrategy.js +98 -0
  106. package/es/plugins/PrepareRendererPlugin.d.ts +6 -0
  107. package/es/plugins/PrepareRendererPlugin.js +65 -0
  108. package/es/property-handlers/aabb.d.ts +2 -0
  109. package/es/property-handlers/aabb.js +132 -0
  110. package/es/property-handlers/anchor.d.ts +4 -0
  111. package/es/property-handlers/anchor.js +20 -0
  112. package/es/property-handlers/clipPath.d.ts +19 -0
  113. package/es/property-handlers/clipPath.js +36 -0
  114. package/es/property-handlers/color.d.ts +34 -0
  115. package/es/property-handlers/color.js +253 -0
  116. package/es/property-handlers/dimension.d.ts +18 -0
  117. package/es/property-handlers/dimension.js +123 -0
  118. package/es/property-handlers/filter.d.ts +8 -0
  119. package/es/property-handlers/filter.js +43 -0
  120. package/es/property-handlers/index.d.ts +18 -0
  121. package/es/property-handlers/index.js +18 -0
  122. package/es/property-handlers/interfaces.d.ts +20 -0
  123. package/es/property-handlers/interfaces.js +6 -0
  124. package/es/property-handlers/lineDash.d.ts +1 -0
  125. package/es/property-handlers/lineDash.js +8 -0
  126. package/es/property-handlers/localPosition.d.ts +2 -0
  127. package/es/property-handlers/localPosition.js +9 -0
  128. package/es/property-handlers/numeric.d.ts +5 -0
  129. package/es/property-handlers/numeric.js +34 -0
  130. package/es/property-handlers/offsetDistance.d.ts +5 -0
  131. package/es/property-handlers/offsetDistance.js +20 -0
  132. package/es/property-handlers/offsetPath.d.ts +5 -0
  133. package/es/property-handlers/offsetPath.js +18 -0
  134. package/es/property-handlers/origin.d.ts +11 -0
  135. package/es/property-handlers/origin.js +68 -0
  136. package/es/property-handlers/path.d.ts +4 -0
  137. package/es/property-handlers/path.js +200 -0
  138. package/es/property-handlers/points.d.ts +5 -0
  139. package/es/property-handlers/points.js +23 -0
  140. package/es/property-handlers/transform.d.ts +45 -0
  141. package/es/property-handlers/transform.js +411 -0
  142. package/es/property-handlers/zIndex.d.ts +2 -0
  143. package/es/property-handlers/zIndex.js +16 -0
  144. package/es/services/ContextService.d.ts +12 -0
  145. package/es/services/ContextService.js +5 -0
  146. package/es/services/EventService.d.ts +64 -0
  147. package/es/services/EventService.js +936 -0
  148. package/es/services/RenderingContext.d.ts +28 -0
  149. package/es/services/RenderingContext.js +13 -0
  150. package/es/services/RenderingService.d.ts +52 -0
  151. package/es/services/RenderingService.js +147 -0
  152. package/es/services/SceneGraphSelector.d.ts +20 -0
  153. package/es/services/SceneGraphSelector.js +65 -0
  154. package/es/services/SceneGraphService.d.ts +150 -0
  155. package/es/services/SceneGraphService.js +853 -0
  156. package/es/services/aabb/CircleUpdater.d.ts +10 -0
  157. package/es/services/aabb/CircleUpdater.js +35 -0
  158. package/es/services/aabb/EllipseUpdater.d.ts +10 -0
  159. package/es/services/aabb/EllipseUpdater.js +37 -0
  160. package/es/services/aabb/LineUpdater.d.ts +10 -0
  161. package/es/services/aabb/LineUpdater.js +39 -0
  162. package/es/services/aabb/PathUpdater.d.ts +10 -0
  163. package/es/services/aabb/PathUpdater.js +172 -0
  164. package/es/services/aabb/PolylineUpdater.d.ts +10 -0
  165. package/es/services/aabb/PolylineUpdater.js +48 -0
  166. package/es/services/aabb/RectUpdater.d.ts +10 -0
  167. package/es/services/aabb/RectUpdater.js +55 -0
  168. package/es/services/aabb/TextUpdater.d.ts +13 -0
  169. package/es/services/aabb/TextUpdater.js +81 -0
  170. package/es/services/aabb/index.d.ts +8 -0
  171. package/es/services/aabb/index.js +8 -0
  172. package/es/services/aabb/interfaces.d.ts +16 -0
  173. package/es/services/aabb/interfaces.js +2 -0
  174. package/es/services/index.d.ts +10 -0
  175. package/es/services/index.js +10 -0
  176. package/es/services/text/OffscreenCanvasCreator.d.ts +6 -0
  177. package/es/services/text/OffscreenCanvasCreator.js +47 -0
  178. package/es/services/text/index.d.ts +35 -0
  179. package/es/services/text/index.js +355 -0
  180. package/es/shapes/AABB.d.ts +34 -0
  181. package/es/shapes/AABB.js +217 -0
  182. package/es/shapes/BoundingSphere.d.ts +8 -0
  183. package/es/shapes/BoundingSphere.js +31 -0
  184. package/es/shapes/Frustum.d.ts +16 -0
  185. package/es/shapes/Frustum.js +79 -0
  186. package/es/shapes/Plane.d.ts +14 -0
  187. package/es/shapes/Plane.js +42 -0
  188. package/es/shapes/Point.d.ts +11 -0
  189. package/es/shapes/Point.js +31 -0
  190. package/es/shapes/Polygon.d.ts +9 -0
  191. package/es/shapes/Polygon.js +64 -0
  192. package/es/shapes/Ray.d.ts +24 -0
  193. package/es/shapes/Ray.js +138 -0
  194. package/es/shapes/Rect.d.ts +12 -0
  195. package/es/shapes/Rect.js +24 -0
  196. package/es/shapes/Rectangle.d.ts +12 -0
  197. package/es/shapes/Rectangle.js +20 -0
  198. package/es/shapes/index.d.ts +8 -0
  199. package/es/shapes/index.js +8 -0
  200. package/es/types.d.ts +220 -0
  201. package/es/types.js +17 -0
  202. package/es/utils/animation.d.ts +15 -0
  203. package/es/utils/animation.js +251 -0
  204. package/es/utils/bezier-easing.d.ts +20 -0
  205. package/es/utils/bezier-easing.js +90 -0
  206. package/es/utils/canvas.d.ts +5 -0
  207. package/es/utils/canvas.js +15 -0
  208. package/es/utils/custom-easing.d.ts +73 -0
  209. package/es/utils/custom-easing.js +333 -0
  210. package/es/utils/event.d.ts +11 -0
  211. package/es/utils/event.js +69 -0
  212. package/es/utils/index.d.ts +5 -0
  213. package/es/utils/index.js +5 -0
  214. package/es/utils/interpolation.d.ts +3 -0
  215. package/es/utils/interpolation.js +179 -0
  216. package/es/utils/math.d.ts +24 -0
  217. package/es/utils/math.js +165 -0
  218. package/es/utils/path.d.ts +15 -0
  219. package/es/utils/path.js +330 -0
  220. package/es/utils/raf.d.ts +3 -0
  221. package/es/utils/raf.js +16 -0
  222. package/es/utils/text.d.ts +2 -0
  223. package/es/utils/text.js +32 -0
  224. package/lib/AbstractRenderer.d.ts +26 -0
  225. package/lib/AbstractRenderer.js +49 -0
  226. package/lib/Canvas.d.ts +97 -0
  227. package/lib/Canvas.js +427 -0
  228. package/lib/DisplayObjectPool.d.ts +7 -0
  229. package/lib/DisplayObjectPool.js +35 -0
  230. package/lib/camera/Camera.d.ts +279 -0
  231. package/lib/camera/Camera.js +1046 -0
  232. package/lib/camera/Landmark.d.ts +28 -0
  233. package/lib/camera/Landmark.js +75 -0
  234. package/lib/camera/index.d.ts +2 -0
  235. package/lib/camera/index.js +31 -0
  236. package/lib/canvas-module.d.ts +1 -0
  237. package/lib/canvas-module.js +48 -0
  238. package/lib/components/Cullable.d.ts +14 -0
  239. package/lib/components/Cullable.js +36 -0
  240. package/lib/components/Geometry.d.ts +12 -0
  241. package/lib/components/Geometry.js +17 -0
  242. package/lib/components/Renderable.d.ts +24 -0
  243. package/lib/components/Renderable.js +25 -0
  244. package/lib/components/Sortable.d.ts +16 -0
  245. package/lib/components/Sortable.js +22 -0
  246. package/lib/components/Transform.d.ts +29 -0
  247. package/lib/components/Transform.js +72 -0
  248. package/lib/components/index.d.ts +5 -0
  249. package/lib/components/index.js +70 -0
  250. package/lib/display-objects/Circle.d.ts +12 -0
  251. package/lib/display-objects/Circle.js +34 -0
  252. package/lib/display-objects/CustomElement.d.ts +22 -0
  253. package/lib/display-objects/CustomElement.js +87 -0
  254. package/lib/display-objects/DisplayObject.d.ts +259 -0
  255. package/lib/display-objects/DisplayObject.js +877 -0
  256. package/lib/display-objects/Ellipse.d.ts +14 -0
  257. package/lib/display-objects/Ellipse.js +35 -0
  258. package/lib/display-objects/Group.d.ts +6 -0
  259. package/lib/display-objects/Group.js +36 -0
  260. package/lib/display-objects/HTML.d.ts +36 -0
  261. package/lib/display-objects/HTML.js +105 -0
  262. package/lib/display-objects/Image.d.ts +16 -0
  263. package/lib/display-objects/Image.js +33 -0
  264. package/lib/display-objects/Line.d.ts +23 -0
  265. package/lib/display-objects/Line.js +68 -0
  266. package/lib/display-objects/Path.d.ts +47 -0
  267. package/lib/display-objects/Path.js +143 -0
  268. package/lib/display-objects/Polygon.d.ts +12 -0
  269. package/lib/display-objects/Polygon.js +33 -0
  270. package/lib/display-objects/Polyline.d.ts +23 -0
  271. package/lib/display-objects/Polyline.js +85 -0
  272. package/lib/display-objects/Rect.d.ts +16 -0
  273. package/lib/display-objects/Rect.js +34 -0
  274. package/lib/display-objects/Text.d.ts +65 -0
  275. package/lib/display-objects/Text.js +69 -0
  276. package/lib/display-objects/index.d.ts +13 -0
  277. package/lib/display-objects/index.js +174 -0
  278. package/lib/dom/Animation.d.ts +132 -0
  279. package/lib/dom/Animation.js +511 -0
  280. package/lib/dom/AnimationEffectTiming.d.ts +58 -0
  281. package/lib/dom/AnimationEffectTiming.js +75 -0
  282. package/lib/dom/AnimationEvent.d.ts +11 -0
  283. package/lib/dom/AnimationEvent.js +42 -0
  284. package/lib/dom/AnimationTimeline.d.ts +37 -0
  285. package/lib/dom/AnimationTimeline.js +230 -0
  286. package/lib/dom/CustomElementRegistry.d.ts +15 -0
  287. package/lib/dom/CustomElementRegistry.js +50 -0
  288. package/lib/dom/CustomEvent.d.ts +16 -0
  289. package/lib/dom/CustomEvent.js +42 -0
  290. package/lib/dom/Document.d.ts +59 -0
  291. package/lib/dom/Document.js +184 -0
  292. package/lib/dom/Element.d.ts +149 -0
  293. package/lib/dom/Element.js +505 -0
  294. package/lib/dom/EventTarget.d.ts +40 -0
  295. package/lib/dom/EventTarget.js +170 -0
  296. package/lib/dom/FederatedEvent.d.ts +146 -0
  297. package/lib/dom/FederatedEvent.js +239 -0
  298. package/lib/dom/FederatedMouseEvent.d.ts +52 -0
  299. package/lib/dom/FederatedMouseEvent.js +133 -0
  300. package/lib/dom/FederatedPointerEvent.d.ts +69 -0
  301. package/lib/dom/FederatedPointerEvent.js +61 -0
  302. package/lib/dom/FederatedWheelEvent.d.ts +20 -0
  303. package/lib/dom/FederatedWheelEvent.js +35 -0
  304. package/lib/dom/KeyframeEffect.d.ts +47 -0
  305. package/lib/dom/KeyframeEffect.js +192 -0
  306. package/lib/dom/KeyframeList.d.ts +2 -0
  307. package/lib/dom/KeyframeList.js +183 -0
  308. package/lib/dom/Node.d.ts +106 -0
  309. package/lib/dom/Node.js +228 -0
  310. package/lib/dom/index.d.ts +17 -0
  311. package/lib/dom/index.js +226 -0
  312. package/lib/dom/interfaces.d.ts +324 -0
  313. package/lib/dom/interfaces.js +40 -0
  314. package/lib/global-module.d.ts +2 -0
  315. package/lib/global-module.js +192 -0
  316. package/lib/index.d.ts +14 -12
  317. package/lib/index.js +203 -24
  318. package/lib/plugins/CullingPlugin.d.ts +19 -0
  319. package/lib/plugins/CullingPlugin.js +90 -0
  320. package/lib/plugins/DirtyCheckPlugin.d.ts +10 -0
  321. package/lib/plugins/DirtyCheckPlugin.js +60 -0
  322. package/lib/plugins/EventPlugin.d.ts +27 -0
  323. package/lib/plugins/EventPlugin.js +297 -0
  324. package/lib/plugins/FrustumCullingStrategy.d.ts +20 -0
  325. package/lib/plugins/FrustumCullingStrategy.js +110 -0
  326. package/lib/plugins/PrepareRendererPlugin.d.ts +6 -0
  327. package/lib/plugins/PrepareRendererPlugin.js +73 -0
  328. package/lib/property-handlers/aabb.d.ts +2 -0
  329. package/lib/property-handlers/aabb.js +148 -0
  330. package/lib/property-handlers/anchor.d.ts +4 -0
  331. package/lib/property-handlers/anchor.js +32 -0
  332. package/lib/property-handlers/clipPath.d.ts +19 -0
  333. package/lib/property-handlers/clipPath.js +43 -0
  334. package/lib/property-handlers/color.d.ts +34 -0
  335. package/lib/property-handlers/color.js +274 -0
  336. package/lib/property-handlers/dimension.d.ts +18 -0
  337. package/lib/property-handlers/dimension.js +144 -0
  338. package/lib/property-handlers/filter.d.ts +8 -0
  339. package/lib/property-handlers/filter.js +56 -0
  340. package/lib/property-handlers/index.d.ts +18 -0
  341. package/lib/property-handlers/index.js +226 -0
  342. package/lib/property-handlers/interfaces.d.ts +20 -0
  343. package/lib/property-handlers/interfaces.js +18 -0
  344. package/lib/property-handlers/lineDash.d.ts +1 -0
  345. package/lib/property-handlers/lineDash.js +15 -0
  346. package/lib/property-handlers/localPosition.d.ts +2 -0
  347. package/lib/property-handlers/localPosition.js +16 -0
  348. package/lib/property-handlers/numeric.d.ts +5 -0
  349. package/lib/property-handlers/numeric.js +50 -0
  350. package/lib/property-handlers/offsetDistance.d.ts +5 -0
  351. package/lib/property-handlers/offsetDistance.js +27 -0
  352. package/lib/property-handlers/offsetPath.d.ts +5 -0
  353. package/lib/property-handlers/offsetPath.js +25 -0
  354. package/lib/property-handlers/origin.d.ts +11 -0
  355. package/lib/property-handlers/origin.js +79 -0
  356. package/lib/property-handlers/path.d.ts +4 -0
  357. package/lib/property-handlers/path.js +214 -0
  358. package/lib/property-handlers/points.d.ts +5 -0
  359. package/lib/property-handlers/points.js +33 -0
  360. package/lib/property-handlers/transform.d.ts +45 -0
  361. package/lib/property-handlers/transform.js +426 -0
  362. package/lib/property-handlers/zIndex.d.ts +2 -0
  363. package/lib/property-handlers/zIndex.js +23 -0
  364. package/lib/services/ContextService.d.ts +12 -0
  365. package/lib/services/ContextService.js +15 -0
  366. package/lib/services/EventService.d.ts +64 -0
  367. package/lib/services/EventService.js +960 -0
  368. package/lib/services/RenderingContext.d.ts +28 -0
  369. package/lib/services/RenderingContext.js +22 -0
  370. package/lib/services/RenderingService.d.ts +52 -0
  371. package/lib/services/RenderingService.js +159 -0
  372. package/lib/services/SceneGraphSelector.d.ts +20 -0
  373. package/lib/services/SceneGraphSelector.js +77 -0
  374. package/lib/services/SceneGraphService.d.ts +150 -0
  375. package/lib/services/SceneGraphService.js +902 -0
  376. package/lib/services/aabb/CircleUpdater.d.ts +10 -0
  377. package/lib/services/aabb/CircleUpdater.js +45 -0
  378. package/lib/services/aabb/EllipseUpdater.d.ts +10 -0
  379. package/lib/services/aabb/EllipseUpdater.js +47 -0
  380. package/lib/services/aabb/LineUpdater.d.ts +10 -0
  381. package/lib/services/aabb/LineUpdater.js +49 -0
  382. package/lib/services/aabb/PathUpdater.d.ts +10 -0
  383. package/lib/services/aabb/PathUpdater.js +183 -0
  384. package/lib/services/aabb/PolylineUpdater.d.ts +10 -0
  385. package/lib/services/aabb/PolylineUpdater.js +58 -0
  386. package/lib/services/aabb/RectUpdater.d.ts +10 -0
  387. package/lib/services/aabb/RectUpdater.js +66 -0
  388. package/lib/services/aabb/TextUpdater.d.ts +13 -0
  389. package/lib/services/aabb/TextUpdater.js +93 -0
  390. package/lib/services/aabb/index.d.ts +8 -0
  391. package/lib/services/aabb/index.js +84 -0
  392. package/lib/services/aabb/interfaces.d.ts +16 -0
  393. package/lib/services/aabb/interfaces.js +10 -0
  394. package/lib/services/index.d.ts +10 -0
  395. package/lib/services/index.js +122 -0
  396. package/lib/services/text/OffscreenCanvasCreator.d.ts +6 -0
  397. package/lib/services/text/OffscreenCanvasCreator.js +55 -0
  398. package/lib/services/text/index.d.ts +35 -0
  399. package/lib/services/text/index.js +364 -0
  400. package/lib/shapes/AABB.d.ts +34 -0
  401. package/lib/shapes/AABB.js +235 -0
  402. package/lib/shapes/BoundingSphere.d.ts +8 -0
  403. package/lib/shapes/BoundingSphere.js +41 -0
  404. package/lib/shapes/Frustum.d.ts +16 -0
  405. package/lib/shapes/Frustum.js +96 -0
  406. package/lib/shapes/Plane.d.ts +14 -0
  407. package/lib/shapes/Plane.js +51 -0
  408. package/lib/shapes/Point.d.ts +11 -0
  409. package/lib/shapes/Point.js +38 -0
  410. package/lib/shapes/Polygon.d.ts +9 -0
  411. package/lib/shapes/Polygon.js +71 -0
  412. package/lib/shapes/Ray.d.ts +24 -0
  413. package/lib/shapes/Ray.js +169 -0
  414. package/lib/shapes/Rect.d.ts +12 -0
  415. package/lib/shapes/Rect.js +31 -0
  416. package/lib/shapes/Rectangle.d.ts +12 -0
  417. package/lib/shapes/Rectangle.js +27 -0
  418. package/lib/shapes/index.d.ts +8 -13
  419. package/lib/shapes/index.js +108 -28
  420. package/lib/types.d.ts +220 -0
  421. package/lib/types.js +25 -0
  422. package/lib/utils/animation.d.ts +15 -0
  423. package/lib/utils/animation.js +275 -0
  424. package/lib/utils/bezier-easing.d.ts +20 -0
  425. package/lib/utils/bezier-easing.js +128 -0
  426. package/lib/utils/canvas.d.ts +5 -0
  427. package/lib/utils/canvas.js +21 -0
  428. package/lib/utils/custom-easing.d.ts +73 -0
  429. package/lib/utils/custom-easing.js +416 -0
  430. package/lib/utils/event.d.ts +11 -0
  431. package/lib/utils/event.js +88 -0
  432. package/lib/utils/index.d.ts +5 -0
  433. package/lib/utils/index.js +70 -0
  434. package/lib/utils/interpolation.d.ts +3 -0
  435. package/lib/utils/interpolation.js +194 -0
  436. package/lib/utils/math.d.ts +24 -0
  437. package/lib/utils/math.js +192 -0
  438. package/lib/utils/path.d.ts +15 -0
  439. package/lib/utils/path.js +356 -0
  440. package/lib/utils/raf.d.ts +3 -0
  441. package/lib/utils/raf.js +22 -0
  442. package/lib/utils/text.d.ts +2 -0
  443. package/lib/utils/text.js +41 -0
  444. package/package.json +35 -92
  445. package/dist/g.min.js +0 -17
  446. package/dist/g.min.js.map +0 -1
  447. package/esm/canvas.d.ts +0 -39
  448. package/esm/canvas.js +0 -378
  449. package/esm/canvas.js.map +0 -1
  450. package/esm/core/attribute.d.ts +0 -49
  451. package/esm/core/attribute.js +0 -277
  452. package/esm/core/attribute.js.map +0 -1
  453. package/esm/core/base.d.ts +0 -32
  454. package/esm/core/base.js +0 -190
  455. package/esm/core/base.js.map +0 -1
  456. package/esm/core/bbox.d.ts +0 -22
  457. package/esm/core/bbox.js +0 -34
  458. package/esm/core/bbox.js.map +0 -1
  459. package/esm/core/element.d.ts +0 -19
  460. package/esm/core/element.js +0 -203
  461. package/esm/core/element.js.map +0 -1
  462. package/esm/core/group.d.ts +0 -72
  463. package/esm/core/group.js +0 -437
  464. package/esm/core/group.js.map +0 -1
  465. package/esm/core/shape.d.ts +0 -35
  466. package/esm/core/shape.js +0 -158
  467. package/esm/core/shape.js.map +0 -1
  468. package/esm/core/timeline.d.ts +0 -15
  469. package/esm/core/timeline.js +0 -179
  470. package/esm/core/timeline.js.map +0 -1
  471. package/esm/event.d.ts +0 -25
  472. package/esm/event.js +0 -37
  473. package/esm/event.js.map +0 -1
  474. package/esm/index.d.ts +0 -13
  475. package/esm/index.js +0 -14
  476. package/esm/index.js.map +0 -1
  477. package/esm/interface.d.ts +0 -18
  478. package/esm/interface.js +0 -1
  479. package/esm/interface.js.map +0 -1
  480. package/esm/renderers/canvas/index.d.ts +0 -1
  481. package/esm/renderers/canvas/index.js +0 -2
  482. package/esm/renderers/canvas/index.js.map +0 -1
  483. package/esm/renderers/canvas/painter.d.ts +0 -17
  484. package/esm/renderers/canvas/painter.js +0 -152
  485. package/esm/renderers/canvas/painter.js.map +0 -1
  486. package/esm/renderers/canvas/util.d.ts +0 -2
  487. package/esm/renderers/canvas/util.js +0 -187
  488. package/esm/renderers/canvas/util.js.map +0 -1
  489. package/esm/renderers/index.d.ts +0 -3
  490. package/esm/renderers/index.js +0 -4
  491. package/esm/renderers/index.js.map +0 -1
  492. package/esm/renderers/svg/defs/arrow.d.ts +0 -15
  493. package/esm/renderers/svg/defs/arrow.js +0 -68
  494. package/esm/renderers/svg/defs/arrow.js.map +0 -1
  495. package/esm/renderers/svg/defs/clip.d.ts +0 -12
  496. package/esm/renderers/svg/defs/clip.js +0 -29
  497. package/esm/renderers/svg/defs/clip.js.map +0 -1
  498. package/esm/renderers/svg/defs/gradient.d.ts +0 -10
  499. package/esm/renderers/svg/defs/gradient.js +0 -117
  500. package/esm/renderers/svg/defs/gradient.js.map +0 -1
  501. package/esm/renderers/svg/defs/pattern.d.ts +0 -10
  502. package/esm/renderers/svg/defs/pattern.js +0 -46
  503. package/esm/renderers/svg/defs/pattern.js.map +0 -1
  504. package/esm/renderers/svg/defs/shadow.d.ts +0 -13
  505. package/esm/renderers/svg/defs/shadow.js +0 -62
  506. package/esm/renderers/svg/defs/shadow.js.map +0 -1
  507. package/esm/renderers/svg/defs.d.ts +0 -18
  508. package/esm/renderers/svg/defs.js +0 -90
  509. package/esm/renderers/svg/defs.js.map +0 -1
  510. package/esm/renderers/svg/get-shape.d.ts +0 -1
  511. package/esm/renderers/svg/get-shape.js +0 -28
  512. package/esm/renderers/svg/get-shape.js.map +0 -1
  513. package/esm/renderers/svg/index.d.ts +0 -2
  514. package/esm/renderers/svg/index.js +0 -3
  515. package/esm/renderers/svg/index.js.map +0 -1
  516. package/esm/renderers/svg/painter.d.ts +0 -32
  517. package/esm/renderers/svg/painter.js +0 -695
  518. package/esm/renderers/svg/painter.js.map +0 -1
  519. package/esm/shapes/arc.d.ts +0 -25
  520. package/esm/shapes/arc.js +0 -107
  521. package/esm/shapes/arc.js.map +0 -1
  522. package/esm/shapes/circle.d.ts +0 -17
  523. package/esm/shapes/circle.js +0 -62
  524. package/esm/shapes/circle.js.map +0 -1
  525. package/esm/shapes/dom.d.ts +0 -10
  526. package/esm/shapes/dom.js +0 -35
  527. package/esm/shapes/dom.js.map +0 -1
  528. package/esm/shapes/ellipse.d.ts +0 -18
  529. package/esm/shapes/ellipse.js +0 -88
  530. package/esm/shapes/ellipse.js.map +0 -1
  531. package/esm/shapes/fan.d.ts +0 -21
  532. package/esm/shapes/fan.js +0 -151
  533. package/esm/shapes/fan.js.map +0 -1
  534. package/esm/shapes/image.d.ts +0 -24
  535. package/esm/shapes/image.js +0 -154
  536. package/esm/shapes/image.js.map +0 -1
  537. package/esm/shapes/index.d.ts +0 -13
  538. package/esm/shapes/index.js +0 -14
  539. package/esm/shapes/index.js.map +0 -1
  540. package/esm/shapes/interface.d.ts +0 -3
  541. package/esm/shapes/interface.js +0 -1
  542. package/esm/shapes/interface.js.map +0 -1
  543. package/esm/shapes/line.d.ts +0 -22
  544. package/esm/shapes/line.js +0 -70
  545. package/esm/shapes/line.js.map +0 -1
  546. package/esm/shapes/marker/index.d.ts +0 -30
  547. package/esm/shapes/marker/index.js +0 -90
  548. package/esm/shapes/marker/index.js.map +0 -1
  549. package/esm/shapes/marker/symbols.d.ts +0 -14
  550. package/esm/shapes/marker/symbols.js +0 -39
  551. package/esm/shapes/marker/symbols.js.map +0 -1
  552. package/esm/shapes/math/arc.d.ts +0 -6
  553. package/esm/shapes/math/arc.js +0 -113
  554. package/esm/shapes/math/arc.js.map +0 -1
  555. package/esm/shapes/math/cubic.d.ts +0 -7
  556. package/esm/shapes/math/cubic.js +0 -141
  557. package/esm/shapes/math/cubic.js.map +0 -1
  558. package/esm/shapes/math/ellipse.d.ts +0 -4
  559. package/esm/shapes/math/ellipse.js +0 -13
  560. package/esm/shapes/math/ellipse.js.map +0 -1
  561. package/esm/shapes/math/line.d.ts +0 -5
  562. package/esm/shapes/math/line.js +0 -23
  563. package/esm/shapes/math/line.js.map +0 -1
  564. package/esm/shapes/math/quadratic.d.ts +0 -5
  565. package/esm/shapes/math/quadratic.js +0 -74
  566. package/esm/shapes/math/quadratic.js.map +0 -1
  567. package/esm/shapes/path.d.ts +0 -25
  568. package/esm/shapes/path.js +0 -270
  569. package/esm/shapes/path.js.map +0 -1
  570. package/esm/shapes/polygon.d.ts +0 -15
  571. package/esm/shapes/polygon.js +0 -103
  572. package/esm/shapes/polygon.js.map +0 -1
  573. package/esm/shapes/polyline.d.ts +0 -24
  574. package/esm/shapes/polyline.js +0 -171
  575. package/esm/shapes/polyline.js.map +0 -1
  576. package/esm/shapes/rect.d.ts +0 -19
  577. package/esm/shapes/rect.js +0 -107
  578. package/esm/shapes/rect.js.map +0 -1
  579. package/esm/shapes/text.d.ts +0 -35
  580. package/esm/shapes/text.js +0 -262
  581. package/esm/shapes/text.js.map +0 -1
  582. package/esm/shapes/util/arrow.d.ts +0 -3
  583. package/esm/shapes/util/arrow.js +0 -131
  584. package/esm/shapes/util/arrow.js.map +0 -1
  585. package/esm/shapes/util/inside.d.ts +0 -9
  586. package/esm/shapes/util/inside.js +0 -50
  587. package/esm/shapes/util/inside.js.map +0 -1
  588. package/esm/shapes/util/is-point-in-path-by-ctx.d.ts +0 -2
  589. package/esm/shapes/util/is-point-in-path-by-ctx.js +0 -8
  590. package/esm/shapes/util/is-point-in-path-by-ctx.js.map +0 -1
  591. package/esm/shapes/util/path-segment.d.ts +0 -18
  592. package/esm/shapes/util/path-segment.js +0 -594
  593. package/esm/shapes/util/path-segment.js.map +0 -1
  594. package/esm/util/format.d.ts +0 -7
  595. package/esm/util/format.js +0 -60
  596. package/esm/util/format.js.map +0 -1
  597. package/esm/util/path.d.ts +0 -11
  598. package/esm/util/path.js +0 -1327
  599. package/esm/util/path.js.map +0 -1
  600. package/lib/canvas.d.ts +0 -39
  601. package/lib/canvas.js +0 -380
  602. package/lib/canvas.js.map +0 -1
  603. package/lib/core/attribute.d.ts +0 -49
  604. package/lib/core/attribute.js +0 -279
  605. package/lib/core/attribute.js.map +0 -1
  606. package/lib/core/base.d.ts +0 -32
  607. package/lib/core/base.js +0 -192
  608. package/lib/core/base.js.map +0 -1
  609. package/lib/core/bbox.d.ts +0 -22
  610. package/lib/core/bbox.js +0 -36
  611. package/lib/core/bbox.js.map +0 -1
  612. package/lib/core/element.d.ts +0 -19
  613. package/lib/core/element.js +0 -205
  614. package/lib/core/element.js.map +0 -1
  615. package/lib/core/group.d.ts +0 -72
  616. package/lib/core/group.js +0 -439
  617. package/lib/core/group.js.map +0 -1
  618. package/lib/core/shape.d.ts +0 -35
  619. package/lib/core/shape.js +0 -160
  620. package/lib/core/shape.js.map +0 -1
  621. package/lib/core/timeline.d.ts +0 -15
  622. package/lib/core/timeline.js +0 -181
  623. package/lib/core/timeline.js.map +0 -1
  624. package/lib/event.d.ts +0 -25
  625. package/lib/event.js +0 -39
  626. package/lib/event.js.map +0 -1
  627. package/lib/index.js.map +0 -1
  628. package/lib/interface.d.ts +0 -18
  629. package/lib/interface.js +0 -3
  630. package/lib/interface.js.map +0 -1
  631. package/lib/renderers/canvas/index.d.ts +0 -1
  632. package/lib/renderers/canvas/index.js +0 -5
  633. package/lib/renderers/canvas/index.js.map +0 -1
  634. package/lib/renderers/canvas/painter.d.ts +0 -17
  635. package/lib/renderers/canvas/painter.js +0 -154
  636. package/lib/renderers/canvas/painter.js.map +0 -1
  637. package/lib/renderers/canvas/util.d.ts +0 -2
  638. package/lib/renderers/canvas/util.js +0 -191
  639. package/lib/renderers/canvas/util.js.map +0 -1
  640. package/lib/renderers/index.d.ts +0 -3
  641. package/lib/renderers/index.js +0 -7
  642. package/lib/renderers/index.js.map +0 -1
  643. package/lib/renderers/svg/defs/arrow.d.ts +0 -15
  644. package/lib/renderers/svg/defs/arrow.js +0 -70
  645. package/lib/renderers/svg/defs/arrow.js.map +0 -1
  646. package/lib/renderers/svg/defs/clip.d.ts +0 -12
  647. package/lib/renderers/svg/defs/clip.js +0 -31
  648. package/lib/renderers/svg/defs/clip.js.map +0 -1
  649. package/lib/renderers/svg/defs/gradient.d.ts +0 -10
  650. package/lib/renderers/svg/defs/gradient.js +0 -119
  651. package/lib/renderers/svg/defs/gradient.js.map +0 -1
  652. package/lib/renderers/svg/defs/pattern.d.ts +0 -10
  653. package/lib/renderers/svg/defs/pattern.js +0 -48
  654. package/lib/renderers/svg/defs/pattern.js.map +0 -1
  655. package/lib/renderers/svg/defs/shadow.d.ts +0 -13
  656. package/lib/renderers/svg/defs/shadow.js +0 -64
  657. package/lib/renderers/svg/defs/shadow.js.map +0 -1
  658. package/lib/renderers/svg/defs.d.ts +0 -18
  659. package/lib/renderers/svg/defs.js +0 -92
  660. package/lib/renderers/svg/defs.js.map +0 -1
  661. package/lib/renderers/svg/get-shape.d.ts +0 -1
  662. package/lib/renderers/svg/get-shape.js +0 -31
  663. package/lib/renderers/svg/get-shape.js.map +0 -1
  664. package/lib/renderers/svg/index.d.ts +0 -2
  665. package/lib/renderers/svg/index.js +0 -7
  666. package/lib/renderers/svg/index.js.map +0 -1
  667. package/lib/renderers/svg/painter.d.ts +0 -32
  668. package/lib/renderers/svg/painter.js +0 -697
  669. package/lib/renderers/svg/painter.js.map +0 -1
  670. package/lib/shapes/arc.d.ts +0 -25
  671. package/lib/shapes/arc.js +0 -109
  672. package/lib/shapes/arc.js.map +0 -1
  673. package/lib/shapes/circle.d.ts +0 -17
  674. package/lib/shapes/circle.js +0 -64
  675. package/lib/shapes/circle.js.map +0 -1
  676. package/lib/shapes/dom.d.ts +0 -10
  677. package/lib/shapes/dom.js +0 -37
  678. package/lib/shapes/dom.js.map +0 -1
  679. package/lib/shapes/ellipse.d.ts +0 -18
  680. package/lib/shapes/ellipse.js +0 -90
  681. package/lib/shapes/ellipse.js.map +0 -1
  682. package/lib/shapes/fan.d.ts +0 -21
  683. package/lib/shapes/fan.js +0 -153
  684. package/lib/shapes/fan.js.map +0 -1
  685. package/lib/shapes/image.d.ts +0 -24
  686. package/lib/shapes/image.js +0 -156
  687. package/lib/shapes/image.js.map +0 -1
  688. package/lib/shapes/index.js.map +0 -1
  689. package/lib/shapes/interface.d.ts +0 -3
  690. package/lib/shapes/interface.js +0 -3
  691. package/lib/shapes/interface.js.map +0 -1
  692. package/lib/shapes/line.d.ts +0 -22
  693. package/lib/shapes/line.js +0 -72
  694. package/lib/shapes/line.js.map +0 -1
  695. package/lib/shapes/marker/index.d.ts +0 -30
  696. package/lib/shapes/marker/index.js +0 -92
  697. package/lib/shapes/marker/index.js.map +0 -1
  698. package/lib/shapes/marker/symbols.d.ts +0 -14
  699. package/lib/shapes/marker/symbols.js +0 -41
  700. package/lib/shapes/marker/symbols.js.map +0 -1
  701. package/lib/shapes/math/arc.d.ts +0 -6
  702. package/lib/shapes/math/arc.js +0 -115
  703. package/lib/shapes/math/arc.js.map +0 -1
  704. package/lib/shapes/math/cubic.d.ts +0 -7
  705. package/lib/shapes/math/cubic.js +0 -148
  706. package/lib/shapes/math/cubic.js.map +0 -1
  707. package/lib/shapes/math/ellipse.d.ts +0 -4
  708. package/lib/shapes/math/ellipse.js +0 -19
  709. package/lib/shapes/math/ellipse.js.map +0 -1
  710. package/lib/shapes/math/line.d.ts +0 -5
  711. package/lib/shapes/math/line.js +0 -29
  712. package/lib/shapes/math/line.js.map +0 -1
  713. package/lib/shapes/math/quadratic.d.ts +0 -5
  714. package/lib/shapes/math/quadratic.js +0 -80
  715. package/lib/shapes/math/quadratic.js.map +0 -1
  716. package/lib/shapes/path.d.ts +0 -25
  717. package/lib/shapes/path.js +0 -272
  718. package/lib/shapes/path.js.map +0 -1
  719. package/lib/shapes/polygon.d.ts +0 -15
  720. package/lib/shapes/polygon.js +0 -105
  721. package/lib/shapes/polygon.js.map +0 -1
  722. package/lib/shapes/polyline.d.ts +0 -24
  723. package/lib/shapes/polyline.js +0 -173
  724. package/lib/shapes/polyline.js.map +0 -1
  725. package/lib/shapes/rect.d.ts +0 -19
  726. package/lib/shapes/rect.js +0 -109
  727. package/lib/shapes/rect.js.map +0 -1
  728. package/lib/shapes/text.d.ts +0 -35
  729. package/lib/shapes/text.js +0 -264
  730. package/lib/shapes/text.js.map +0 -1
  731. package/lib/shapes/util/arrow.d.ts +0 -3
  732. package/lib/shapes/util/arrow.js +0 -135
  733. package/lib/shapes/util/arrow.js.map +0 -1
  734. package/lib/shapes/util/inside.d.ts +0 -9
  735. package/lib/shapes/util/inside.js +0 -60
  736. package/lib/shapes/util/inside.js.map +0 -1
  737. package/lib/shapes/util/is-point-in-path-by-ctx.d.ts +0 -2
  738. package/lib/shapes/util/is-point-in-path-by-ctx.js +0 -11
  739. package/lib/shapes/util/is-point-in-path-by-ctx.js.map +0 -1
  740. package/lib/shapes/util/path-segment.d.ts +0 -18
  741. package/lib/shapes/util/path-segment.js +0 -596
  742. package/lib/shapes/util/path-segment.js.map +0 -1
  743. package/lib/util/format.d.ts +0 -7
  744. package/lib/util/format.js +0 -64
  745. package/lib/util/format.js.map +0 -1
  746. package/lib/util/path.d.ts +0 -11
  747. package/lib/util/path.js +0 -1338
  748. package/lib/util/path.js.map +0 -1
@@ -0,0 +1,973 @@
1
+ import { __extends } from "tslib";
2
+ import { EventEmitter } from 'eventemitter3';
3
+ import { mat3, mat4, quat, vec3, vec4 } from 'gl-matrix';
4
+ import { Landmark } from './Landmark';
5
+ import { Frustum } from '../shapes';
6
+ import { createVec3, getAngle, makePerspective } from '../utils/math';
7
+ import { requestAnimationFrame, cancelAnimationFrame } from '../utils/raf';
8
+ export var DefaultCamera = 'DefaultCamera';
9
+ export var CAMERA_TYPE;
10
+
11
+ (function (CAMERA_TYPE) {
12
+ CAMERA_TYPE["ORBITING"] = "ORBITING";
13
+ CAMERA_TYPE["EXPLORING"] = "EXPLORING";
14
+ CAMERA_TYPE["TRACKING"] = "TRACKING";
15
+ })(CAMERA_TYPE || (CAMERA_TYPE = {}));
16
+
17
+ export var CAMERA_TRACKING_MODE;
18
+
19
+ (function (CAMERA_TRACKING_MODE) {
20
+ CAMERA_TRACKING_MODE["DEFAULT"] = "DEFAULT";
21
+ CAMERA_TRACKING_MODE["ROTATIONAL"] = "ROTATIONAL";
22
+ CAMERA_TRACKING_MODE["TRANSLATIONAL"] = "TRANSLATIONAL";
23
+ CAMERA_TRACKING_MODE["CINEMATIC"] = "CINEMATIC";
24
+ })(CAMERA_TRACKING_MODE || (CAMERA_TRACKING_MODE = {}));
25
+
26
+ export var CAMERA_PROJECTION_MODE;
27
+
28
+ (function (CAMERA_PROJECTION_MODE) {
29
+ CAMERA_PROJECTION_MODE["ORTHOGRAPHIC"] = "ORTHOGRAPHIC";
30
+ CAMERA_PROJECTION_MODE["PERSPECTIVE"] = "PERSPECTIVE";
31
+ })(CAMERA_PROJECTION_MODE || (CAMERA_PROJECTION_MODE = {}));
32
+
33
+ export var CAMERA_EVENT = {
34
+ Updated: 'updated'
35
+ };
36
+ var DEG_2_RAD = Math.PI / 180;
37
+ var RAD_2_DEG = 180 / Math.PI;
38
+ /**
39
+ * 参考「WebGL Insights - 23.Designing Cameras for WebGL Applications」,基于 Responsible Camera 思路设计
40
+ * 保存相机参数,定义相机动作:
41
+ * 1. dolly 沿 n 轴移动
42
+ * 2. pan 沿 u v 轴移动
43
+ * 3. rotate 以方位角旋转
44
+ * 4. 移动到 Landmark,具有平滑的动画效果,其间禁止其他用户交互
45
+ */
46
+
47
+ var Camera =
48
+ /** @class */
49
+ function (_super) {
50
+ __extends(Camera, _super);
51
+
52
+ function Camera() {
53
+ var _this = _super !== null && _super.apply(this, arguments) || this;
54
+ /**
55
+ * 相机矩阵
56
+ */
57
+
58
+
59
+ _this.matrix = mat4.create();
60
+ /**
61
+ * u 轴
62
+ * @see http://learnwebgl.brown37.net/07_cameras/camera_introduction.html#a-camera-definition
63
+ */
64
+
65
+ _this.right = vec3.fromValues(1, 0, 0);
66
+ /**
67
+ * v 轴 +Y is down
68
+ */
69
+
70
+ _this.up = vec3.fromValues(0, 1, 0);
71
+ /**
72
+ * n 轴 +Z is inside
73
+ */
74
+
75
+ _this.forward = vec3.fromValues(0, 0, 1);
76
+ /**
77
+ * 相机位置
78
+ */
79
+
80
+ _this.position = vec3.fromValues(0, 0, 1);
81
+ /**
82
+ * 视点位置
83
+ */
84
+
85
+ _this.focalPoint = vec3.fromValues(0, 0, 0);
86
+ /**
87
+ * 相机位置到视点向量
88
+ * focalPoint - position
89
+ */
90
+
91
+ _this.distanceVector = vec3.fromValues(0, 0, 0);
92
+ /**
93
+ * 相机位置到视点距离
94
+ * length(focalPoint - position)
95
+ */
96
+
97
+ _this.distance = 1;
98
+ /**
99
+ * @see https://en.wikipedia.org/wiki/Azimuth
100
+ */
101
+
102
+ _this.azimuth = 0;
103
+ _this.elevation = 0;
104
+ _this.roll = 0;
105
+ _this.relAzimuth = 0;
106
+ _this.relElevation = 0;
107
+ _this.relRoll = 0;
108
+ /**
109
+ * 沿 n 轴移动时,保证移动速度从快到慢
110
+ */
111
+
112
+ _this.dollyingStep = 0;
113
+ _this.maxDistance = Infinity;
114
+ _this.minDistance = -Infinity;
115
+ /**
116
+ * zoom factor of the camera, default is 1
117
+ * eg. https://threejs.org/docs/#api/en/cameras/OrthographicCamera.zoom
118
+ */
119
+
120
+ _this.zoom = 1;
121
+ /**
122
+ * invert the horizontal coordinate system HCS
123
+ */
124
+
125
+ _this.rotateWorld = false; // @inject(IDENTIFIER.InteractorService)
126
+ // interactor: IInteractorService;
127
+
128
+ /**
129
+ * 投影矩阵参数
130
+ */
131
+
132
+ /**
133
+ * field of view [0-360]
134
+ * @see http://en.wikipedia.org/wiki/Angle_of_view
135
+ */
136
+
137
+ _this.fov = 30;
138
+ _this.near = 0.1;
139
+ _this.far = 10000;
140
+ _this.aspect = 1;
141
+ _this.projectionMatrix = mat4.create();
142
+ _this.projectionMatrixInverse = mat4.create();
143
+ _this.jitteredProjectionMatrix = undefined;
144
+ _this.following = undefined;
145
+ _this.type = CAMERA_TYPE.EXPLORING;
146
+ _this.trackingMode = CAMERA_TRACKING_MODE.DEFAULT;
147
+ _this.projectionMode = CAMERA_PROJECTION_MODE.PERSPECTIVE;
148
+ /**
149
+ * for culling use
150
+ */
151
+
152
+ _this.frustum = new Frustum();
153
+ /**
154
+ * switch between multiple landmarks
155
+ */
156
+
157
+ _this.landmarks = [];
158
+ /**
159
+ * ortho matrix for Canvas2D & SVG
160
+ */
161
+
162
+ _this.orthoMatrix = mat4.create();
163
+ return _this;
164
+ }
165
+
166
+ Camera.prototype.clone = function () {
167
+ var camera = new Camera();
168
+ camera.setType(this.type, undefined); // camera.interactor = this.interactor;
169
+
170
+ return camera;
171
+ };
172
+
173
+ Camera.prototype.getProjectionMode = function () {
174
+ return this.projectionMode;
175
+ };
176
+
177
+ Camera.prototype.getPerspective = function () {
178
+ // account for TAA
179
+ return this.jitteredProjectionMatrix || this.projectionMatrix;
180
+ };
181
+
182
+ Camera.prototype.getPerspectiveInverse = function () {
183
+ return this.projectionMatrixInverse;
184
+ };
185
+
186
+ Camera.prototype.getFrustum = function () {
187
+ return this.frustum;
188
+ };
189
+
190
+ Camera.prototype.getPosition = function () {
191
+ return this.position;
192
+ };
193
+
194
+ Camera.prototype.getFocalPoint = function () {
195
+ return this.focalPoint;
196
+ };
197
+
198
+ Camera.prototype.getNear = function () {
199
+ return this.near;
200
+ };
201
+
202
+ Camera.prototype.getFar = function () {
203
+ return this.far;
204
+ };
205
+
206
+ Camera.prototype.getZoom = function () {
207
+ return this.zoom;
208
+ };
209
+
210
+ Camera.prototype.getOrthoMatrix = function () {
211
+ return this.orthoMatrix;
212
+ };
213
+
214
+ Camera.prototype.setType = function (type, trackingMode) {
215
+ this.type = type;
216
+
217
+ if (this.type === CAMERA_TYPE.EXPLORING) {
218
+ this.setWorldRotation(true);
219
+ } else {
220
+ this.setWorldRotation(false);
221
+ }
222
+
223
+ this._getAngles();
224
+
225
+ if (this.type === CAMERA_TYPE.TRACKING && trackingMode !== undefined) {
226
+ this.setTrackingMode(trackingMode);
227
+ }
228
+
229
+ return this;
230
+ };
231
+
232
+ Camera.prototype.setProjectionMode = function (projectionMode) {
233
+ this.projectionMode = projectionMode;
234
+ return this;
235
+ };
236
+
237
+ Camera.prototype.setTrackingMode = function (trackingMode) {
238
+ if (this.type !== CAMERA_TYPE.TRACKING) {
239
+ throw new Error('Impossible to set a tracking mode if the camera is not of tracking type');
240
+ }
241
+
242
+ this.trackingMode = trackingMode;
243
+ return this;
244
+ };
245
+ /**
246
+ * If flag is true, it reverses the azimuth and elevation angles.
247
+ * Subsequent calls to rotate, setAzimuth, setElevation,
248
+ * changeAzimuth or changeElevation will cause the inverted effect.
249
+ * setRoll or changeRoll is not affected by this method.
250
+ *
251
+ * This inversion is useful when one wants to simulate that the world
252
+ * is moving, instead of the camera.
253
+ *
254
+ * By default the camera angles are not reversed.
255
+ * @param {Boolean} flag the boolean flag to reverse the angles.
256
+ */
257
+
258
+
259
+ Camera.prototype.setWorldRotation = function (flag) {
260
+ this.rotateWorld = flag;
261
+
262
+ this._getAngles();
263
+ };
264
+ /**
265
+ * 计算 MV 矩阵,为相机矩阵的逆矩阵
266
+ */
267
+
268
+
269
+ Camera.prototype.getViewTransform = function () {
270
+ return mat4.invert(mat4.create(), this.matrix);
271
+ };
272
+
273
+ Camera.prototype.getWorldTransform = function () {
274
+ return this.matrix;
275
+ };
276
+
277
+ Camera.prototype.jitterProjectionMatrix = function (x, y) {
278
+ var translation = mat4.fromTranslation(mat4.create(), [x, y, 0]);
279
+ this.jitteredProjectionMatrix = mat4.multiply(mat4.create(), translation, this.projectionMatrix);
280
+ };
281
+
282
+ Camera.prototype.clearJitterProjectionMatrix = function () {
283
+ this.jitteredProjectionMatrix = undefined;
284
+ };
285
+ /**
286
+ * 设置相机矩阵
287
+ */
288
+
289
+
290
+ Camera.prototype.setMatrix = function (matrix) {
291
+ this.matrix = matrix;
292
+
293
+ this._update();
294
+
295
+ return this;
296
+ };
297
+
298
+ Camera.prototype.setFov = function (fov) {
299
+ this.setPerspective(this.near, this.far, fov, this.aspect);
300
+ };
301
+
302
+ Camera.prototype.setAspect = function (aspect) {
303
+ this.setPerspective(this.near, this.far, this.fov, aspect);
304
+ return this;
305
+ };
306
+
307
+ Camera.prototype.setNear = function (near) {
308
+ if (this.projectionMode === CAMERA_PROJECTION_MODE.PERSPECTIVE) {
309
+ this.setPerspective(near, this.far, this.fov, this.aspect);
310
+ } else {
311
+ this.setOrthographic(this.left, this.rright, this.top, this.bottom, near, this.far);
312
+ }
313
+
314
+ return this;
315
+ };
316
+
317
+ Camera.prototype.setFar = function (far) {
318
+ if (this.projectionMode === CAMERA_PROJECTION_MODE.PERSPECTIVE) {
319
+ this.setPerspective(this.near, far, this.fov, this.aspect);
320
+ } else {
321
+ this.setOrthographic(this.left, this.rright, this.top, this.bottom, this.near, far);
322
+ }
323
+
324
+ return this;
325
+ };
326
+ /**
327
+ * Sets an offset in a larger frustum, used in PixelPicking
328
+ */
329
+
330
+
331
+ Camera.prototype.setViewOffset = function (fullWidth, fullHeight, x, y, width, height) {
332
+ this.aspect = fullWidth / fullHeight;
333
+
334
+ if (this.view === undefined) {
335
+ this.view = {
336
+ enabled: true,
337
+ fullWidth: 1,
338
+ fullHeight: 1,
339
+ offsetX: 0,
340
+ offsetY: 0,
341
+ width: 1,
342
+ height: 1
343
+ };
344
+ }
345
+
346
+ this.view.enabled = true;
347
+ this.view.fullWidth = fullWidth;
348
+ this.view.fullHeight = fullHeight;
349
+ this.view.offsetX = x;
350
+ this.view.offsetY = y;
351
+ this.view.width = width;
352
+ this.view.height = height;
353
+
354
+ if (this.projectionMode === CAMERA_PROJECTION_MODE.PERSPECTIVE) {
355
+ this.setPerspective(this.near, this.far, this.fov, this.aspect);
356
+ } else {
357
+ this.setOrthographic(this.left, this.rright, this.top, this.bottom, this.near, this.far);
358
+ }
359
+
360
+ return this;
361
+ };
362
+
363
+ Camera.prototype.clearViewOffset = function () {
364
+ if (this.view !== undefined) {
365
+ this.view.enabled = false;
366
+ }
367
+
368
+ if (this.projectionMode === CAMERA_PROJECTION_MODE.PERSPECTIVE) {
369
+ this.setPerspective(this.near, this.far, this.fov, this.aspect);
370
+ } else {
371
+ this.setOrthographic(this.left, this.rright, this.top, this.bottom, this.near, this.far);
372
+ }
373
+
374
+ return this;
375
+ };
376
+
377
+ Camera.prototype.setZoom = function (zoom) {
378
+ this.zoom = zoom;
379
+
380
+ if (this.projectionMode === CAMERA_PROJECTION_MODE.ORTHOGRAPHIC) {
381
+ this.setOrthographic(this.left, this.rright, this.top, this.bottom, this.near, this.far);
382
+ } else if (this.projectionMode === CAMERA_PROJECTION_MODE.PERSPECTIVE) {
383
+ this.setPerspective(this.near, this.far, this.fov, this.aspect);
384
+ }
385
+
386
+ return this;
387
+ };
388
+
389
+ Camera.prototype.setPerspective = function (near, far, fov, aspect) {
390
+ this.projectionMode = CAMERA_PROJECTION_MODE.PERSPECTIVE;
391
+ this.fov = fov;
392
+ this.near = near;
393
+ this.far = far;
394
+ this.aspect = aspect;
395
+ var top = this.near * Math.tan(DEG_2_RAD * 0.5 * this.fov) / this.zoom;
396
+ var height = 2 * top;
397
+ var width = this.aspect * height;
398
+ var left = -0.5 * width;
399
+
400
+ if (this.view !== undefined && this.view.enabled) {
401
+ var fullWidth = this.view.fullWidth;
402
+ var fullHeight = this.view.fullHeight;
403
+ left += this.view.offsetX * width / fullWidth;
404
+ top -= this.view.offsetY * height / fullHeight;
405
+ width *= this.view.width / fullWidth;
406
+ height *= this.view.height / fullHeight;
407
+ } // flip Y
408
+
409
+
410
+ makePerspective(this.projectionMatrix, left, left + width, top - height, top, near, this.far);
411
+ mat4.invert(this.projectionMatrixInverse, this.projectionMatrix);
412
+ this.emit(CAMERA_EVENT.Updated);
413
+ return this;
414
+ };
415
+
416
+ Camera.prototype.setOrthographic = function (l, r, t, b, near, far) {
417
+ this.projectionMode = CAMERA_PROJECTION_MODE.ORTHOGRAPHIC;
418
+ this.rright = r;
419
+ this.left = l;
420
+ this.top = t;
421
+ this.bottom = b;
422
+ this.near = near;
423
+ this.far = far;
424
+ var dx = (this.rright - this.left) / (2 * this.zoom);
425
+ var dy = (this.top - this.bottom) / (2 * this.zoom);
426
+ var cx = (this.rright + this.left) / 2;
427
+ var cy = (this.top + this.bottom) / 2;
428
+ var left = cx - dx;
429
+ var right = cx + dx;
430
+ var top = cy + dy;
431
+ var bottom = cy - dy;
432
+
433
+ if (this.view !== undefined && this.view.enabled) {
434
+ var scaleW = (this.rright - this.left) / this.view.fullWidth / this.zoom;
435
+ var scaleH = (this.top - this.bottom) / this.view.fullHeight / this.zoom;
436
+ left += scaleW * this.view.offsetX;
437
+ right = left + scaleW * this.view.width;
438
+ top -= scaleH * this.view.offsetY;
439
+ bottom = top - scaleH * this.view.height;
440
+ }
441
+
442
+ mat4.ortho(this.projectionMatrix, left, right, bottom, top, near, far);
443
+ mat4.invert(this.projectionMatrixInverse, this.projectionMatrix);
444
+
445
+ this._getOrthoMatrix();
446
+
447
+ this.emit(CAMERA_EVENT.Updated);
448
+ return this;
449
+ };
450
+ /**
451
+ * 设置相机位置
452
+ */
453
+
454
+
455
+ Camera.prototype.setPosition = function (x, y, z) {
456
+ if (y === void 0) {
457
+ y = 0;
458
+ }
459
+
460
+ if (z === void 0) {
461
+ z = 0;
462
+ }
463
+
464
+ this._setPosition(x, y, z);
465
+
466
+ this.setFocalPoint(this.focalPoint);
467
+ return this;
468
+ };
469
+ /**
470
+ * 设置视点位置
471
+ */
472
+
473
+
474
+ Camera.prototype.setFocalPoint = function (x, y, z) {
475
+ var up = vec3.fromValues(0, 1, 0);
476
+ this.focalPoint = createVec3(x, y, z);
477
+
478
+ if (this.trackingMode === CAMERA_TRACKING_MODE.CINEMATIC) {
479
+ var d = vec3.subtract(vec3.create(), this.focalPoint, this.position);
480
+ x = d[0];
481
+ y = d[1];
482
+ z = d[2];
483
+ var r = vec3.length(d);
484
+ var el = Math.asin(y / r) * RAD_2_DEG;
485
+ var az = 90 + Math.atan2(z, x) * RAD_2_DEG;
486
+ var m = mat4.create();
487
+ mat4.rotateY(m, m, az * DEG_2_RAD);
488
+ mat4.rotateX(m, m, el * DEG_2_RAD);
489
+ up = vec3.transformMat4(vec3.create(), [0, 1, 0], m);
490
+ }
491
+
492
+ mat4.invert(this.matrix, mat4.lookAt(mat4.create(), this.position, this.focalPoint, up));
493
+
494
+ this._getAxes();
495
+
496
+ this._getDistance();
497
+
498
+ this._getAngles();
499
+
500
+ return this;
501
+ };
502
+ /**
503
+ * 固定当前视点,按指定距离放置相机
504
+ */
505
+
506
+
507
+ Camera.prototype.setDistance = function (d) {
508
+ if (this.distance === d || d < 0) {
509
+ return;
510
+ }
511
+
512
+ this.distance = d;
513
+
514
+ if (this.distance < 0.0002) {
515
+ this.distance = 0.0002;
516
+ }
517
+
518
+ this.dollyingStep = this.distance / 100;
519
+ var pos = vec3.create();
520
+ d = this.distance;
521
+ var n = this.forward;
522
+ var f = this.focalPoint;
523
+ pos[0] = d * n[0] + f[0];
524
+ pos[1] = d * n[1] + f[1];
525
+ pos[2] = d * n[2] + f[2];
526
+
527
+ this._setPosition(pos);
528
+
529
+ return this;
530
+ };
531
+
532
+ Camera.prototype.setMaxDistance = function (d) {
533
+ this.maxDistance = d;
534
+ return this;
535
+ };
536
+
537
+ Camera.prototype.setMinDistance = function (d) {
538
+ this.minDistance = d;
539
+ return this;
540
+ };
541
+ /**
542
+ * Changes the initial azimuth of the camera
543
+ */
544
+
545
+
546
+ Camera.prototype.changeAzimuth = function (az) {
547
+ this.setAzimuth(this.azimuth + az);
548
+ return this;
549
+ };
550
+ /**
551
+ * Changes the initial elevation of the camera
552
+ */
553
+
554
+
555
+ Camera.prototype.changeElevation = function (el) {
556
+ this.setElevation(this.elevation + el);
557
+ return this;
558
+ };
559
+ /**
560
+ * Changes the initial roll of the camera
561
+ */
562
+
563
+
564
+ Camera.prototype.changeRoll = function (rl) {
565
+ this.setRoll(this.roll + rl);
566
+ return this;
567
+ };
568
+ /**
569
+ * 设置相机方位角,不同相机模式下需要重新计算相机位置或者是视点位置
570
+ * @param {Number} el the azimuth in degrees
571
+ */
572
+
573
+
574
+ Camera.prototype.setAzimuth = function (az) {
575
+ this.azimuth = getAngle(az);
576
+ this.computeMatrix();
577
+
578
+ this._getAxes();
579
+
580
+ if (this.type === CAMERA_TYPE.ORBITING || this.type === CAMERA_TYPE.EXPLORING) {
581
+ this._getPosition();
582
+ } else if (this.type === CAMERA_TYPE.TRACKING) {
583
+ this._getFocalPoint();
584
+ }
585
+
586
+ return this;
587
+ };
588
+
589
+ Camera.prototype.getAzimuth = function () {
590
+ return this.azimuth;
591
+ };
592
+ /**
593
+ * 设置相机方位角,不同相机模式下需要重新计算相机位置或者是视点位置
594
+ * @param {Number} el the elevation in degrees
595
+ */
596
+
597
+
598
+ Camera.prototype.setElevation = function (el) {
599
+ this.elevation = getAngle(el);
600
+ this.computeMatrix();
601
+
602
+ this._getAxes();
603
+
604
+ if (this.type === CAMERA_TYPE.ORBITING || this.type === CAMERA_TYPE.EXPLORING) {
605
+ this._getPosition();
606
+ } else if (this.type === CAMERA_TYPE.TRACKING) {
607
+ this._getFocalPoint();
608
+ }
609
+
610
+ return this;
611
+ };
612
+ /**
613
+ * 设置相机方位角,不同相机模式下需要重新计算相机位置或者是视点位置
614
+ * @param {Number} angle the roll angle
615
+ */
616
+
617
+
618
+ Camera.prototype.setRoll = function (angle) {
619
+ this.roll = getAngle(angle);
620
+ this.computeMatrix();
621
+
622
+ this._getAxes();
623
+
624
+ if (this.type === CAMERA_TYPE.ORBITING || this.type === CAMERA_TYPE.EXPLORING) {
625
+ this._getPosition();
626
+ } else if (this.type === CAMERA_TYPE.TRACKING) {
627
+ this._getFocalPoint();
628
+ }
629
+
630
+ return this;
631
+ };
632
+ /**
633
+ * Changes the azimuth and elevation with respect to the current camera axes
634
+ * @param {Number} azimuth the relative azimuth
635
+ * @param {Number} elevation the relative elevation
636
+ * @param {Number} roll the relative roll
637
+ */
638
+
639
+
640
+ Camera.prototype.rotate = function (azimuth, elevation, roll) {
641
+ this.relElevation = getAngle(elevation);
642
+ this.relAzimuth = getAngle(azimuth);
643
+ this.relRoll = getAngle(roll);
644
+ this.elevation += this.relElevation;
645
+ this.azimuth += this.relAzimuth;
646
+ this.roll += this.relRoll;
647
+
648
+ if (this.type === CAMERA_TYPE.EXPLORING) {
649
+ var rotX = quat.setAxisAngle(quat.create(), [1, 0, 0], (this.rotateWorld ? 1 : -1) * this.relElevation * DEG_2_RAD);
650
+ var rotY = quat.setAxisAngle(quat.create(), [0, 1, 0], (this.rotateWorld ? 1 : -1) * this.relAzimuth * DEG_2_RAD);
651
+ var rotZ = quat.setAxisAngle(quat.create(), [0, 0, 1], this.relRoll * DEG_2_RAD);
652
+ var rotQ = quat.multiply(quat.create(), rotY, rotX);
653
+ rotQ = quat.multiply(quat.create(), rotQ, rotZ);
654
+ var rotMatrix = mat4.fromQuat(mat4.create(), rotQ);
655
+ mat4.translate(this.matrix, this.matrix, [0, 0, -this.distance]);
656
+ mat4.multiply(this.matrix, this.matrix, rotMatrix);
657
+ mat4.translate(this.matrix, this.matrix, [0, 0, this.distance]);
658
+ } else {
659
+ if (Math.abs(this.elevation) > 90) {
660
+ return;
661
+ }
662
+
663
+ this.computeMatrix();
664
+ }
665
+
666
+ this._getAxes();
667
+
668
+ if (this.type === CAMERA_TYPE.ORBITING || this.type === CAMERA_TYPE.EXPLORING) {
669
+ this._getPosition();
670
+ } else if (this.type === CAMERA_TYPE.TRACKING) {
671
+ this._getFocalPoint();
672
+ }
673
+
674
+ this._update();
675
+
676
+ return this;
677
+ };
678
+ /**
679
+ * 沿水平(right) & 垂直(up)平移相机
680
+ */
681
+
682
+
683
+ Camera.prototype.pan = function (tx, ty) {
684
+ var coords = createVec3(tx, ty, 0);
685
+ var pos = vec3.clone(this.position);
686
+ vec3.add(pos, pos, vec3.scale(vec3.create(), this.right, coords[0]));
687
+ vec3.add(pos, pos, vec3.scale(vec3.create(), this.up, coords[1]));
688
+
689
+ this._setPosition(pos);
690
+
691
+ this.emit(CAMERA_EVENT.Updated);
692
+ return this;
693
+ };
694
+ /**
695
+ * 沿 n 轴移动,当距离视点远时移动速度较快,离视点越近速度越慢
696
+ */
697
+
698
+
699
+ Camera.prototype.dolly = function (value) {
700
+ var n = this.forward;
701
+ var pos = vec3.clone(this.position);
702
+ var step = value * this.dollyingStep;
703
+ var updatedDistance = this.distance + value * this.dollyingStep; // 限制视点距离范围
704
+
705
+ step = Math.max(Math.min(updatedDistance, this.maxDistance), this.minDistance) - this.distance;
706
+ pos[0] += step * n[0];
707
+ pos[1] += step * n[1];
708
+ pos[2] += step * n[2];
709
+
710
+ this._setPosition(pos);
711
+
712
+ if (this.type === CAMERA_TYPE.ORBITING || this.type === CAMERA_TYPE.EXPLORING) {
713
+ // 重新计算视点距离
714
+ this._getDistance();
715
+ } else if (this.type === CAMERA_TYPE.TRACKING) {
716
+ // 保持视距,移动视点位置
717
+ vec3.add(this.focalPoint, pos, this.distanceVector);
718
+ }
719
+
720
+ this.emit(CAMERA_EVENT.Updated);
721
+ return this;
722
+ };
723
+
724
+ Camera.prototype.createLandmark = function (name, params) {
725
+ var camera = this.clone();
726
+ camera.setPosition(params.position);
727
+ camera.setFocalPoint(params.focalPoint);
728
+
729
+ if (params.roll !== undefined) {
730
+ camera.setRoll(params.roll);
731
+ }
732
+
733
+ var landmark = new Landmark(name, camera);
734
+ this.landmarks.push(landmark);
735
+ return landmark;
736
+ };
737
+
738
+ Camera.prototype.setLandmark = function (name) {
739
+ var landmark = new Landmark(name, this);
740
+ this.landmarks.push(landmark);
741
+ return this;
742
+ };
743
+
744
+ Camera.prototype.gotoLandmark = function (name, duration) {
745
+ var _this = this;
746
+
747
+ if (duration === void 0) {
748
+ duration = 1000;
749
+ }
750
+
751
+ var landmark = this.landmarks.find(function (l) {
752
+ return l.name === name;
753
+ });
754
+
755
+ if (landmark) {
756
+ if (duration === 0) {
757
+ landmark.retrieve(this);
758
+ return;
759
+ }
760
+
761
+ if (this.landmarkAnimationID !== undefined) {
762
+ cancelAnimationFrame(this.landmarkAnimationID);
763
+ } // TODO: do not process events during animation
764
+ // this.interactor.disconnect();
765
+
766
+
767
+ var destPosition_1 = landmark.getPosition();
768
+ var destFocalPoint_1 = landmark.getFocalPoint();
769
+ var destRoll_1 = landmark.getRoll();
770
+ var timeStart_1;
771
+
772
+ var animate_1 = function animate_1(timestamp) {
773
+ if (timeStart_1 === undefined) {
774
+ timeStart_1 = timestamp;
775
+ }
776
+
777
+ var elapsed = timestamp - timeStart_1; // TODO: use better ease function
778
+
779
+ var t = (1 - Math.cos(elapsed / duration * Math.PI)) / 2;
780
+ var interFocalPoint = vec3.create();
781
+ var interPosition = vec3.create();
782
+ var interRoll = 0;
783
+ vec3.lerp(interFocalPoint, _this.focalPoint, destFocalPoint_1, t);
784
+ vec3.lerp(interPosition, _this.position, destPosition_1, t);
785
+ interRoll = _this.roll * (1 - t) + destRoll_1 * t;
786
+
787
+ _this.setFocalPoint(interFocalPoint);
788
+
789
+ _this.setPosition(interPosition);
790
+
791
+ _this.setRoll(interRoll);
792
+
793
+ _this.computeMatrix();
794
+
795
+ _this.emit(CAMERA_EVENT.Updated);
796
+
797
+ var dist = vec3.dist(interFocalPoint, destFocalPoint_1) + vec3.dist(interPosition, destPosition_1);
798
+
799
+ if (dist > 0.01) {//
800
+ } else {
801
+ _this.setFocalPoint(interFocalPoint);
802
+
803
+ _this.setPosition(interPosition);
804
+
805
+ _this.setRoll(interRoll);
806
+
807
+ _this.computeMatrix(); // this.interactor.connect();
808
+
809
+
810
+ return;
811
+ }
812
+
813
+ if (elapsed < duration) {
814
+ _this.landmarkAnimationID = requestAnimationFrame(animate_1);
815
+ }
816
+ };
817
+
818
+ requestAnimationFrame(animate_1);
819
+ }
820
+ };
821
+ /**
822
+ * 根据相机矩阵重新计算各种相机参数
823
+ */
824
+
825
+
826
+ Camera.prototype._update = function () {
827
+ this._getAxes();
828
+
829
+ this._getPosition();
830
+
831
+ this._getDistance();
832
+
833
+ this._getAngles();
834
+
835
+ this._getOrthoMatrix();
836
+
837
+ this.emit(CAMERA_EVENT.Updated);
838
+ };
839
+ /**
840
+ * 计算相机矩阵
841
+ */
842
+
843
+
844
+ Camera.prototype.computeMatrix = function () {
845
+ // 使用四元数描述 3D 旋转
846
+ // @see https://xiaoiver.github.io/coding/2018/12/28/Camera-%E8%AE%BE%E8%AE%A1-%E4%B8%80.html
847
+ var rotZ = quat.setAxisAngle(quat.create(), [0, 0, 1], this.roll * DEG_2_RAD);
848
+ mat4.identity(this.matrix); // only consider HCS for EXPLORING and ORBITING cameras
849
+
850
+ var rotX = quat.setAxisAngle(quat.create(), [1, 0, 0], (this.rotateWorld && this.type !== CAMERA_TYPE.TRACKING || this.type === CAMERA_TYPE.TRACKING ? 1 : -1) * this.elevation * DEG_2_RAD);
851
+ var rotY = quat.setAxisAngle(quat.create(), [0, 1, 0], (this.rotateWorld && this.type !== CAMERA_TYPE.TRACKING || this.type === CAMERA_TYPE.TRACKING ? 1 : -1) * this.azimuth * DEG_2_RAD);
852
+ var rotQ = quat.multiply(quat.create(), rotY, rotX);
853
+ rotQ = quat.multiply(quat.create(), rotQ, rotZ);
854
+ var rotMatrix = mat4.fromQuat(mat4.create(), rotQ);
855
+
856
+ if (this.type === CAMERA_TYPE.ORBITING || this.type === CAMERA_TYPE.EXPLORING) {
857
+ mat4.translate(this.matrix, this.matrix, this.focalPoint);
858
+ mat4.multiply(this.matrix, this.matrix, rotMatrix);
859
+ mat4.translate(this.matrix, this.matrix, [0, 0, this.distance]);
860
+ } else if (this.type === CAMERA_TYPE.TRACKING) {
861
+ mat4.translate(this.matrix, this.matrix, this.position);
862
+ mat4.multiply(this.matrix, this.matrix, rotMatrix);
863
+ }
864
+ };
865
+ /**
866
+ * Sets the camera position in the camera matrix
867
+ */
868
+
869
+
870
+ Camera.prototype._setPosition = function (x, y, z) {
871
+ this.position = createVec3(x, y, z);
872
+ var m = this.matrix;
873
+ m[12] = this.position[0];
874
+ m[13] = this.position[1];
875
+ m[14] = this.position[2];
876
+ m[15] = 1;
877
+
878
+ this._getOrthoMatrix();
879
+ };
880
+ /**
881
+ * Recalculates axes based on the current matrix
882
+ */
883
+
884
+
885
+ Camera.prototype._getAxes = function () {
886
+ vec3.copy(this.right, createVec3(vec4.transformMat4(vec4.create(), [1, 0, 0, 0], this.matrix)));
887
+ vec3.copy(this.up, createVec3(vec4.transformMat4(vec4.create(), [0, 1, 0, 0], this.matrix)));
888
+ vec3.copy(this.forward, createVec3(vec4.transformMat4(vec4.create(), [0, 0, 1, 0], this.matrix)));
889
+ vec3.normalize(this.right, this.right);
890
+ vec3.normalize(this.up, this.up);
891
+ vec3.normalize(this.forward, this.forward);
892
+ };
893
+ /**
894
+ * Recalculates euler angles based on the current state
895
+ */
896
+
897
+
898
+ Camera.prototype._getAngles = function () {
899
+ // Recalculates angles
900
+ var x = this.distanceVector[0];
901
+ var y = this.distanceVector[1];
902
+ var z = this.distanceVector[2];
903
+ var r = vec3.length(this.distanceVector); // FAST FAIL: If there is no distance we cannot compute angles
904
+
905
+ if (r === 0) {
906
+ this.elevation = 0;
907
+ this.azimuth = 0;
908
+ return;
909
+ }
910
+
911
+ if (this.type === CAMERA_TYPE.TRACKING) {
912
+ this.elevation = Math.asin(y / r) * RAD_2_DEG;
913
+ this.azimuth = Math.atan2(-x, -z) * RAD_2_DEG;
914
+ } else {
915
+ if (this.rotateWorld) {
916
+ this.elevation = Math.asin(y / r) * RAD_2_DEG;
917
+ this.azimuth = Math.atan2(-x, -z) * RAD_2_DEG;
918
+ } else {
919
+ this.elevation = -Math.asin(y / r) * RAD_2_DEG;
920
+ this.azimuth = -Math.atan2(-x, -z) * RAD_2_DEG;
921
+ }
922
+ }
923
+ };
924
+ /**
925
+ * 重新计算相机位置,只有 ORBITING 模式相机位置才会发生变化
926
+ */
927
+
928
+
929
+ Camera.prototype._getPosition = function () {
930
+ vec3.copy(this.position, createVec3(vec4.transformMat4(vec4.create(), [0, 0, 0, 1], this.matrix))); // 相机位置变化,需要重新计算视距
931
+
932
+ this._getDistance();
933
+ };
934
+ /**
935
+ * 重新计算视点,只有 TRACKING 模式视点才会发生变化
936
+ */
937
+
938
+
939
+ Camera.prototype._getFocalPoint = function () {
940
+ vec3.transformMat3(this.distanceVector, [0, 0, -this.distance], mat3.fromMat4(mat3.create(), this.matrix));
941
+ vec3.add(this.focalPoint, this.position, this.distanceVector); // 视点变化,需要重新计算视距
942
+
943
+ this._getDistance();
944
+ };
945
+ /**
946
+ * 重新计算视距
947
+ */
948
+
949
+
950
+ Camera.prototype._getDistance = function () {
951
+ this.distanceVector = vec3.subtract(vec3.create(), this.focalPoint, this.position);
952
+ this.distance = vec3.length(this.distanceVector);
953
+ this.dollyingStep = this.distance / 100;
954
+ };
955
+
956
+ Camera.prototype._getOrthoMatrix = function () {
957
+ if (this.projectionMode !== CAMERA_PROJECTION_MODE.ORTHOGRAPHIC) {
958
+ return;
959
+ }
960
+
961
+ var position = this.position;
962
+ var rotZ = quat.setAxisAngle(quat.create(), [0, 0, 1], -this.roll * Math.PI / 180);
963
+ mat4.fromRotationTranslationScaleOrigin(this.orthoMatrix, rotZ, vec3.fromValues((this.rright - this.left) / 2 - position[0], (this.bottom - this.top) / 2 - position[1], 0), vec3.fromValues(this.zoom, this.zoom, 1), position);
964
+ };
965
+
966
+ Camera.ProjectionMode = {
967
+ ORTHOGRAPHIC: 'ORTHOGRAPHIC',
968
+ PERSPECTIVE: 'PERSPECTIVE'
969
+ };
970
+ return Camera;
971
+ }(EventEmitter);
972
+
973
+ export { Camera };