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