@antv/g 5.0.21 → 5.0.22-alpha.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 (265) hide show
  1. package/es/AbstractRenderer.js +1 -3
  2. package/es/Canvas.js +7 -11
  3. package/es/DisplayObjectPool.js +1 -3
  4. package/es/camera/Camera.d.ts +12 -7
  5. package/es/camera/Camera.js +54 -24
  6. package/es/camera/Landmark.d.ts +2 -0
  7. package/es/camera/Landmark.js +10 -6
  8. package/es/components/Cullable.js +1 -3
  9. package/es/components/Geometry.js +1 -3
  10. package/es/components/Renderable.js +1 -3
  11. package/es/components/Sortable.js +1 -3
  12. package/es/components/Transform.js +1 -3
  13. package/es/css/LayoutRegistry.js +1 -3
  14. package/es/css/StyleValueRegistry.js +1 -3
  15. package/es/css/cssom/CSSColorValue.js +1 -3
  16. package/es/css/cssom/CSSGradientValue.js +6 -8
  17. package/es/css/cssom/CSSKeywordValue.js +1 -3
  18. package/es/css/cssom/CSSMathInvert.js +1 -3
  19. package/es/css/cssom/CSSMathMax.js +1 -3
  20. package/es/css/cssom/CSSMathMin.js +1 -3
  21. package/es/css/cssom/CSSMathNegate.js +1 -3
  22. package/es/css/cssom/CSSMathProduct.js +1 -3
  23. package/es/css/cssom/CSSMathSum.js +1 -3
  24. package/es/css/cssom/CSSMathValue.js +1 -3
  25. package/es/css/cssom/CSSMathVariadic.js +1 -3
  26. package/es/css/cssom/CSSNumericValue.js +1 -3
  27. package/es/css/cssom/CSSNumericValueType.d.ts +1 -1
  28. package/es/css/cssom/CSSNumericValueType.js +1 -3
  29. package/es/css/cssom/CSSRGB.js +2 -4
  30. package/es/css/cssom/CSSStyleValue.d.ts +2 -2
  31. package/es/css/cssom/CSSStyleValue.js +2 -4
  32. package/es/css/cssom/CSSTransformComponent.js +1 -3
  33. package/es/css/cssom/CSSTransformValue.js +1 -3
  34. package/es/css/cssom/CSSTranslate.js +1 -3
  35. package/es/css/cssom/CSSUnitValue.js +2 -4
  36. package/es/css/parser/color.js +1 -1
  37. package/es/css/parser/dimension.js +1 -1
  38. package/es/css/parser/transform.d.ts +1 -1
  39. package/es/css/parser/transform.js +2 -2
  40. package/es/css/properties/CSSPropertyAnchor.js +1 -3
  41. package/es/css/properties/CSSPropertyClipPath.js +1 -3
  42. package/es/css/properties/CSSPropertyColor.js +1 -3
  43. package/es/css/properties/CSSPropertyFilter.js +1 -3
  44. package/es/css/properties/CSSPropertyLengthOrPercentage.js +1 -3
  45. package/es/css/properties/CSSPropertyLineDash.js +1 -3
  46. package/es/css/properties/CSSPropertyLocalPosition.js +1 -3
  47. package/es/css/properties/CSSPropertyOffsetDistance.js +1 -3
  48. package/es/css/properties/CSSPropertyOffsetPath.js +1 -3
  49. package/es/css/properties/CSSPropertyOpacity.js +1 -3
  50. package/es/css/properties/CSSPropertyPath.js +1 -3
  51. package/es/css/properties/CSSPropertyPoints.js +1 -3
  52. package/es/css/properties/CSSPropertyShadowBlur.js +1 -3
  53. package/es/css/properties/CSSPropertyText.js +2 -4
  54. package/es/css/properties/CSSPropertyTextTransform.js +1 -3
  55. package/es/css/properties/CSSPropertyTransform.js +1 -3
  56. package/es/css/properties/CSSPropertyTransformOrigin.js +1 -3
  57. package/es/css/properties/CSSPropertyVisibility.js +1 -3
  58. package/es/css/properties/CSSPropertyZIndex.js +1 -3
  59. package/es/display-objects/Circle.js +1 -3
  60. package/es/display-objects/CustomElement.js +1 -3
  61. package/es/display-objects/DisplayObject.js +10 -8
  62. package/es/display-objects/Ellipse.js +1 -3
  63. package/es/display-objects/Group.js +1 -3
  64. package/es/display-objects/HTML.js +3 -6
  65. package/es/display-objects/Image.js +1 -3
  66. package/es/display-objects/Line.js +1 -3
  67. package/es/display-objects/Path.js +1 -3
  68. package/es/display-objects/Polygon.js +1 -3
  69. package/es/display-objects/Polyline.js +1 -3
  70. package/es/display-objects/Rect.js +1 -3
  71. package/es/display-objects/Text.js +3 -6
  72. package/es/dom/Animation.js +2 -4
  73. package/es/dom/AnimationEffectTiming.js +1 -3
  74. package/es/dom/AnimationEvent.js +1 -3
  75. package/es/dom/AnimationTimeline.js +1 -3
  76. package/es/dom/CustomElementRegistry.js +1 -3
  77. package/es/dom/CustomEvent.js +1 -3
  78. package/es/dom/Document.js +1 -3
  79. package/es/dom/Element.js +4 -6
  80. package/es/dom/EventTarget.js +3 -5
  81. package/es/dom/FederatedEvent.js +1 -3
  82. package/es/dom/FederatedMouseEvent.js +1 -3
  83. package/es/dom/FederatedPointerEvent.js +1 -3
  84. package/es/dom/FederatedWheelEvent.js +1 -3
  85. package/es/dom/KeyframeEffect.js +1 -3
  86. package/es/dom/KeyframeList.js +1 -1
  87. package/es/dom/MutationEvent.js +1 -3
  88. package/es/dom/MutationObserver.js +3 -10
  89. package/es/dom/MutationRecord.js +1 -3
  90. package/es/dom/Node.js +2 -4
  91. package/es/plugins/CullingPlugin.js +1 -3
  92. package/es/plugins/DirtyCheckPlugin.js +1 -3
  93. package/es/plugins/EventPlugin.js +5 -4
  94. package/es/plugins/FrustumCullingStrategy.js +1 -3
  95. package/es/plugins/PrepareRendererPlugin.js +1 -3
  96. package/es/services/EventService.js +26 -7
  97. package/es/services/OffscreenCanvasCreator.js +1 -3
  98. package/es/services/RenderingContext.d.ts +2 -1
  99. package/es/services/RenderingContext.js +3 -1
  100. package/es/services/RenderingService.js +1 -3
  101. package/es/services/SceneGraphSelector.js +1 -3
  102. package/es/services/SceneGraphService.d.ts +2 -1
  103. package/es/services/SceneGraphService.js +3 -5
  104. package/es/services/TextService.js +3 -5
  105. package/es/services/aabb/CircleUpdater.js +1 -3
  106. package/es/services/aabb/EllipseUpdater.js +1 -3
  107. package/es/services/aabb/LineUpdater.js +1 -3
  108. package/es/services/aabb/PathUpdater.js +1 -3
  109. package/es/services/aabb/PolylineUpdater.js +1 -3
  110. package/es/services/aabb/RectUpdater.js +1 -3
  111. package/es/services/aabb/TextUpdater.js +1 -3
  112. package/es/services/aabb/interfaces.d.ts +3 -2
  113. package/es/services/aabb/interfaces.js +3 -2
  114. package/es/shapes/AABB.js +1 -3
  115. package/es/shapes/BoundingSphere.js +1 -3
  116. package/es/shapes/Frustum.js +1 -3
  117. package/es/shapes/Plane.js +1 -3
  118. package/es/shapes/Point.js +1 -3
  119. package/es/shapes/Ray.js +1 -3
  120. package/es/shapes/Rectangle.js +1 -3
  121. package/es/types.d.ts +2 -1
  122. package/es/types.js +2 -1
  123. package/es/utils/custom-easing.d.ts +0 -9
  124. package/es/utils/custom-easing.js +38 -54
  125. package/es/utils/path.d.ts +1 -1
  126. package/es/utils/path.js +3 -3
  127. package/es/utils/text.js +3 -3
  128. package/lib/AbstractRenderer.js +1 -3
  129. package/lib/Canvas.js +8 -12
  130. package/lib/DisplayObjectPool.js +1 -3
  131. package/lib/camera/Camera.d.ts +12 -7
  132. package/lib/camera/Camera.js +59 -25
  133. package/lib/camera/Landmark.d.ts +2 -0
  134. package/lib/camera/Landmark.js +10 -6
  135. package/lib/components/Cullable.js +2 -4
  136. package/lib/components/Geometry.js +1 -3
  137. package/lib/components/Renderable.js +1 -3
  138. package/lib/components/Sortable.js +1 -3
  139. package/lib/components/Transform.js +1 -3
  140. package/lib/css/LayoutRegistry.js +1 -3
  141. package/lib/css/StyleValueRegistry.js +1 -3
  142. package/lib/css/cssom/CSSColorValue.js +1 -3
  143. package/lib/css/cssom/CSSGradientValue.js +7 -9
  144. package/lib/css/cssom/CSSKeywordValue.js +1 -3
  145. package/lib/css/cssom/CSSMathInvert.js +1 -3
  146. package/lib/css/cssom/CSSMathMax.js +1 -3
  147. package/lib/css/cssom/CSSMathMin.js +1 -3
  148. package/lib/css/cssom/CSSMathNegate.js +1 -3
  149. package/lib/css/cssom/CSSMathOperator.js +1 -1
  150. package/lib/css/cssom/CSSMathProduct.js +1 -3
  151. package/lib/css/cssom/CSSMathSum.js +1 -3
  152. package/lib/css/cssom/CSSMathValue.js +1 -3
  153. package/lib/css/cssom/CSSMathVariadic.js +2 -4
  154. package/lib/css/cssom/CSSNumericValue.js +1 -3
  155. package/lib/css/cssom/CSSNumericValueType.d.ts +1 -1
  156. package/lib/css/cssom/CSSNumericValueType.js +3 -5
  157. package/lib/css/cssom/CSSRGB.js +2 -4
  158. package/lib/css/cssom/CSSStyleValue.d.ts +2 -2
  159. package/lib/css/cssom/CSSStyleValue.js +108 -110
  160. package/lib/css/cssom/CSSTransformComponent.js +2 -4
  161. package/lib/css/cssom/CSSTransformValue.js +1 -3
  162. package/lib/css/cssom/CSSTranslate.js +1 -3
  163. package/lib/css/cssom/CSSUnitValue.js +2 -4
  164. package/lib/css/cssom/types.js +1 -1
  165. package/lib/css/parser/color.js +3 -3
  166. package/lib/css/parser/dimension.js +6 -7
  167. package/lib/css/parser/numeric.js +3 -3
  168. package/lib/css/parser/path.js +1 -1
  169. package/lib/css/parser/transform.d.ts +1 -1
  170. package/lib/css/parser/transform.js +11 -11
  171. package/lib/css/properties/CSSPropertyAnchor.js +1 -3
  172. package/lib/css/properties/CSSPropertyClipPath.js +1 -3
  173. package/lib/css/properties/CSSPropertyColor.js +1 -3
  174. package/lib/css/properties/CSSPropertyFilter.js +1 -3
  175. package/lib/css/properties/CSSPropertyLengthOrPercentage.js +1 -3
  176. package/lib/css/properties/CSSPropertyLineDash.js +1 -3
  177. package/lib/css/properties/CSSPropertyLocalPosition.js +1 -3
  178. package/lib/css/properties/CSSPropertyOffsetDistance.js +1 -3
  179. package/lib/css/properties/CSSPropertyOffsetPath.js +1 -3
  180. package/lib/css/properties/CSSPropertyOpacity.js +1 -3
  181. package/lib/css/properties/CSSPropertyPath.js +1 -3
  182. package/lib/css/properties/CSSPropertyPoints.js +1 -3
  183. package/lib/css/properties/CSSPropertyShadowBlur.js +1 -3
  184. package/lib/css/properties/CSSPropertyText.js +2 -4
  185. package/lib/css/properties/CSSPropertyTextTransform.js +1 -3
  186. package/lib/css/properties/CSSPropertyTransform.js +1 -3
  187. package/lib/css/properties/CSSPropertyTransformOrigin.js +1 -3
  188. package/lib/css/properties/CSSPropertyVisibility.js +1 -3
  189. package/lib/css/properties/CSSPropertyZIndex.js +1 -3
  190. package/lib/display-objects/Circle.js +1 -3
  191. package/lib/display-objects/CustomElement.js +1 -3
  192. package/lib/display-objects/DisplayObject.js +9 -7
  193. package/lib/display-objects/Ellipse.js +1 -3
  194. package/lib/display-objects/Group.js +1 -3
  195. package/lib/display-objects/HTML.js +4 -6
  196. package/lib/display-objects/Image.js +1 -3
  197. package/lib/display-objects/Line.js +1 -3
  198. package/lib/display-objects/Path.js +1 -3
  199. package/lib/display-objects/Polygon.js +1 -3
  200. package/lib/display-objects/Polyline.js +1 -3
  201. package/lib/display-objects/Rect.js +1 -3
  202. package/lib/display-objects/Text.js +4 -6
  203. package/lib/dom/Animation.js +2 -4
  204. package/lib/dom/AnimationEffectTiming.js +1 -3
  205. package/lib/dom/AnimationEvent.js +1 -3
  206. package/lib/dom/AnimationTimeline.js +2 -4
  207. package/lib/dom/CustomElementRegistry.js +1 -3
  208. package/lib/dom/CustomEvent.js +1 -3
  209. package/lib/dom/Document.js +1 -3
  210. package/lib/dom/Element.js +4 -6
  211. package/lib/dom/EventTarget.js +3 -5
  212. package/lib/dom/FederatedEvent.js +1 -3
  213. package/lib/dom/FederatedMouseEvent.js +1 -3
  214. package/lib/dom/FederatedPointerEvent.js +1 -3
  215. package/lib/dom/FederatedWheelEvent.js +1 -3
  216. package/lib/dom/KeyframeEffect.js +2 -4
  217. package/lib/dom/KeyframeList.js +1 -1
  218. package/lib/dom/MutationEvent.js +1 -3
  219. package/lib/dom/MutationObserver.js +4 -11
  220. package/lib/dom/MutationRecord.js +1 -3
  221. package/lib/dom/Node.js +2 -4
  222. package/lib/index.js +1 -1
  223. package/lib/plugins/CullingPlugin.js +2 -4
  224. package/lib/plugins/DirtyCheckPlugin.js +1 -3
  225. package/lib/plugins/EventPlugin.js +5 -4
  226. package/lib/plugins/FrustumCullingStrategy.js +1 -3
  227. package/lib/plugins/PrepareRendererPlugin.js +1 -3
  228. package/lib/services/EventService.js +26 -7
  229. package/lib/services/OffscreenCanvasCreator.js +1 -3
  230. package/lib/services/RenderingContext.d.ts +2 -1
  231. package/lib/services/RenderingContext.js +4 -1
  232. package/lib/services/RenderingService.js +1 -3
  233. package/lib/services/SceneGraphSelector.js +2 -4
  234. package/lib/services/SceneGraphService.d.ts +2 -1
  235. package/lib/services/SceneGraphService.js +5 -6
  236. package/lib/services/TextService.js +3 -5
  237. package/lib/services/aabb/CircleUpdater.js +1 -3
  238. package/lib/services/aabb/EllipseUpdater.js +1 -3
  239. package/lib/services/aabb/LineUpdater.js +1 -3
  240. package/lib/services/aabb/PathUpdater.js +1 -3
  241. package/lib/services/aabb/PolylineUpdater.js +1 -3
  242. package/lib/services/aabb/RectUpdater.js +1 -3
  243. package/lib/services/aabb/TextUpdater.js +1 -3
  244. package/lib/services/aabb/index.js +10 -10
  245. package/lib/services/aabb/interfaces.d.ts +3 -2
  246. package/lib/services/aabb/interfaces.js +9 -3
  247. package/lib/shapes/AABB.js +1 -3
  248. package/lib/shapes/BoundingSphere.js +1 -3
  249. package/lib/shapes/Frustum.js +2 -4
  250. package/lib/shapes/Plane.js +1 -3
  251. package/lib/shapes/Point.js +1 -3
  252. package/lib/shapes/Ray.js +1 -3
  253. package/lib/shapes/Rectangle.js +1 -3
  254. package/lib/types.d.ts +2 -1
  255. package/lib/types.js +6 -2
  256. package/lib/utils/animation.js +2 -3
  257. package/lib/utils/bezier-easing.js +1 -1
  258. package/lib/utils/custom-easing.d.ts +0 -9
  259. package/lib/utils/custom-easing.js +42 -66
  260. package/lib/utils/math.js +9 -9
  261. package/lib/utils/path.d.ts +1 -1
  262. package/lib/utils/path.js +6 -6
  263. package/lib/utils/text.js +3 -3
  264. package/package.json +3 -3
  265. package/dist/index.umd.min.js +0 -30
@@ -1,6 +1,4 @@
1
- var Rectangle =
2
- /** @class */
3
- function () {
1
+ var Rectangle = function () {
4
2
  function Rectangle(x, y, width, height) {
5
3
  this.x = x;
6
4
  this.y = y;
package/es/types.d.ts CHANGED
@@ -4,6 +4,7 @@ import type { ParsedPathStyleProps, ParsedPolylineStyleProps } from './display-o
4
4
  import type { DisplayObject } from './display-objects';
5
5
  import type { IRenderer } from './AbstractRenderer';
6
6
  import type { CSSGlobalKeywords, CSSGradientValue, CSSKeywordValue, CSSRGB, CSSUnitValue } from './css';
7
+ import { Syringe } from 'mana-syringe';
7
8
  export declare enum Shape {
8
9
  GROUP = "g",
9
10
  CIRCLE = "circle",
@@ -209,7 +210,7 @@ export interface RendererConfig {
209
210
  */
210
211
  enableTAA: boolean;
211
212
  }
212
- export declare const CanvasConfig = "CanvasConfig";
213
+ export declare const CanvasConfig: Syringe.DefinedToken;
213
214
  export interface CanvasConfig {
214
215
  /**
215
216
  * Renderer
package/es/types.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { Syringe } from 'mana-syringe';
1
2
  export var Shape;
2
3
 
3
4
  (function (Shape) {
@@ -49,4 +50,4 @@ export var TextAlign;
49
50
  TextAlign["RIGHT"] = "right";
50
51
  })(TextAlign || (TextAlign = {}));
51
52
 
52
- export var CanvasConfig = 'CanvasConfig';
53
+ export var CanvasConfig = Syringe.defineToken('CanvasConfig');
@@ -38,7 +38,6 @@ export declare const parseEasingParameters: (str: string) => (string | number)[]
38
38
  * easing functions, because of the nature of the function it can sometimes create an infinite loop, I suggest only using
39
39
  * `getEasingDuration` for `spring`, specifically 'out-spring' and 'spring'
40
40
  */
41
- export declare const getEasingDuration: (easing?: string | TypeEasingFunction) => number;
42
41
  /**
43
42
  These Easing Functions are based off of the Sozi Project's easing functions
44
43
  https://github.com/sozi-projects/Sozi/blob/d72e44ebd580dc7579d1e177406ad41e632f961d/src/js/player/Timing.js
@@ -63,11 +62,3 @@ export declare const EasingFunctions: Record<string, TypeEasingFunction>;
63
62
  export declare const complexEasingSyntax: (ease: string) => string;
64
63
  /** Re-maps a number from one range to another. Numbers outside the range are not clamped to 0 and 1, because out-of-range values are often intentional and useful. */
65
64
  export declare const getEasingFunction: (ease: string) => TypeEasingFunction;
66
- /**
67
- * Allows you to register new easing functions
68
- */
69
- export declare const registerEasingFunction: (key: string, fn: TypeEasingFunction) => void;
70
- /**
71
- * Allows you to register multiple new easing functions
72
- */
73
- export declare const registerEasingFunctions: (...obj: (typeof EasingFunctions)[]) => void;
@@ -1,4 +1,4 @@
1
- import { __read, __spreadArray } from "tslib";
1
+ import { __read } from "tslib";
2
2
  /**
3
3
  * ported from https://github.com/okikio/native/blob/master/packages/animate/src/custom-easing.ts
4
4
  */
@@ -6,7 +6,7 @@ import { __read, __spreadArray } from "tslib";
6
6
  import { bezier } from './bezier-easing';
7
7
  export var convertToDash = function convertToDash(str) {
8
8
  str = str.replace(/([A-Z])/g, function (letter) {
9
- return "-".concat(letter.toLowerCase());
9
+ return "-" + letter.toLowerCase();
10
10
  }); // Remove first dash
11
11
 
12
12
  return str.charAt(0) === '-' ? str.substr(1) : str;
@@ -128,36 +128,29 @@ export var parseEasingParameters = function parseEasingParameters(str) {
128
128
  * easing functions, because of the nature of the function it can sometimes create an infinite loop, I suggest only using
129
129
  * `getEasingDuration` for `spring`, specifically 'out-spring' and 'spring'
130
130
  */
131
+ // export const getEasingDuration = (easing: string | TypeEasingFunction = 'spring') => {
132
+ // if (EasingDurationCache.has(easing)) return EasingDurationCache.get(easing);
133
+ // // eslint-disable-next-line @typescript-eslint/no-use-before-define
134
+ // const easingFunction = typeof easing == 'function' ? easing : getEasingFunction(easing as string);
135
+ // const params = typeof easing == 'function' ? [] : parseEasingParameters(easing);
136
+ // const frame = 1 / 6;
137
+ // let elapsed = 0;
138
+ // let rest = 0;
139
+ // let count = 0;
140
+ // while (++count < INTINITE_LOOP_LIMIT) {
141
+ // elapsed += frame;
142
+ // if (easingFunction(elapsed, params, undefined) === 1) {
143
+ // rest++;
144
+ // if (rest >= 16) break;
145
+ // } else {
146
+ // rest = 0;
147
+ // }
148
+ // }
149
+ // const duration = elapsed * frame * 1000;
150
+ // EasingDurationCache.set(easing, duration);
151
+ // return duration;
152
+ // };
131
153
 
132
- export var getEasingDuration = function getEasingDuration(easing) {
133
- if (easing === void 0) {
134
- easing = 'spring';
135
- }
136
-
137
- if (EasingDurationCache.has(easing)) return EasingDurationCache.get(easing); // eslint-disable-next-line @typescript-eslint/no-use-before-define
138
-
139
- var easingFunction = typeof easing == 'function' ? easing : getEasingFunction(easing);
140
- var params = typeof easing == 'function' ? [] : parseEasingParameters(easing);
141
- var frame = 1 / 6;
142
- var elapsed = 0;
143
- var rest = 0;
144
- var count = 0;
145
-
146
- while (++count < INTINITE_LOOP_LIMIT) {
147
- elapsed += frame;
148
-
149
- if (easingFunction(elapsed, params, undefined) === 1) {
150
- rest++;
151
- if (rest >= 16) break;
152
- } else {
153
- rest = 0;
154
- }
155
- }
156
-
157
- var duration = elapsed * frame * 1000;
158
- EasingDurationCache.set(easing, duration);
159
- return duration;
160
- };
161
154
  /**
162
155
  These Easing Functions are based off of the Sozi Project's easing functions
163
156
  https://github.com/sozi-projects/Sozi/blob/d72e44ebd580dc7579d1e177406ad41e632f961d/src/js/player/Timing.js
@@ -308,26 +301,17 @@ export var complexEasingSyntax = function complexEasingSyntax(ease) {
308
301
 
309
302
  export var getEasingFunction = function getEasingFunction(ease) {
310
303
  return EasingFunctions[complexEasingSyntax(ease)] || EasingFunctions.linear;
311
- };
312
- /**
313
- * Allows you to register new easing functions
314
- */
315
-
316
- export var registerEasingFunction = function registerEasingFunction(key, fn) {
317
- var _a;
318
-
319
- Object.assign(EasingFunctions, (_a = {}, _a[key] = fn, _a));
320
- };
321
- /**
322
- * Allows you to register multiple new easing functions
323
- */
324
-
325
- export var registerEasingFunctions = function registerEasingFunctions() {
326
- var obj = [];
327
-
328
- for (var _i = 0; _i < arguments.length; _i++) {
329
- obj[_i] = arguments[_i];
330
- }
331
-
332
- Object.assign.apply(Object, __spreadArray([EasingFunctions], __read(obj), false));
333
- };
304
+ }; // /**
305
+ // * Allows you to register new easing functions
306
+ // */
307
+ // export const registerEasingFunction = (key: string, fn: TypeEasingFunction) => {
308
+ // Object.assign(EasingFunctions, {
309
+ // [key]: fn,
310
+ // });
311
+ // };
312
+ // /**
313
+ // * Allows you to register multiple new easing functions
314
+ // */
315
+ // export const registerEasingFunctions = (...obj: typeof EasingFunctions[]) => {
316
+ // Object.assign(EasingFunctions, ...obj);
317
+ // };
@@ -5,7 +5,7 @@ export declare function getDrawDirection(pathArray: PathCommand[]): boolean;
5
5
  export declare function getPathArea(pathArray: PathCommand[]): number;
6
6
  export declare function reverseCurve(pathArray: PathCommand[]): PathCommand[];
7
7
  export declare function clonePath(pathArray: PathCommand[]): PathCommand[];
8
- export declare function getRotatedCurve(a: PathCommand[], b: PathCommand[]): (string[] | ["a" | "A", number, number, number, number, number, number, number] | ["C" | "c", number, number, number, number, number, number] | ["o" | "O", number, number] | ["h" | "H", number] | ["l" | "L", number, number] | ["m" | "M", number, number] | ["r" | "R", number, number, number, number] | ["q" | "Q", number, number, number, number] | ["s" | "S", number, number, number, number, number, number, number] | ["t" | "T", number, number] | ["v" | "V", number] | ["U" | "u", number, number, number])[];
8
+ export declare function getRotatedCurve(a: PathCommand[], b: PathCommand[]): (string[] | ["a" | "A", number, number, number, number, number, number, number] | ["c" | "C", number, number, number, number, number, number] | ["o" | "O", number, number] | ["h" | "H", number] | ["l" | "L", number, number] | ["m" | "M", number, number] | ["r" | "R", number, number, number, number] | ["Q" | "q", number, number, number, number] | ["s" | "S", number, number, number, number, number, number, number] | ["t" | "T", number, number] | ["v" | "V", number] | ["u" | "U", number, number, number])[];
9
9
  /**
10
10
  * convert object to path, should account for:
11
11
  * * transform & origin
package/es/utils/path.js CHANGED
@@ -216,7 +216,7 @@ function commandsToPathString(commands, localTransform, anchor, parsedStyle) {
216
216
  if (cur[0] === 'M' || cur[0] === 'L') {
217
217
  var p = vec3.fromValues(cur[1] - defX, cur[2] - defY, 0);
218
218
  vec3.transformMat4(p, p, localTransform);
219
- path = "".concat(cur[0]).concat(p[0], ",").concat(p[1]);
219
+ path = "" + cur[0] + p[0] + "," + p[1];
220
220
  } else if (cur[0] === 'Z') {
221
221
  path = cur[0];
222
222
  } else if (cur[0] === 'C') {
@@ -226,11 +226,11 @@ function commandsToPathString(commands, localTransform, anchor, parsedStyle) {
226
226
  vec3.transformMat4(p1, p1, localTransform);
227
227
  vec3.transformMat4(p2, p2, localTransform);
228
228
  vec3.transformMat4(p3, p3, localTransform);
229
- path = "".concat(cur[0]).concat(p1[0], ",").concat(p1[1], ",").concat(p2[0], ",").concat(p2[1], ",").concat(p3[0], ",").concat(p3[1]);
229
+ path = "" + cur[0] + p1[0] + "," + p1[1] + "," + p2[0] + "," + p2[1] + "," + p3[0] + "," + p3[1];
230
230
  } else if (cur[0] === 'A') {
231
231
  var c = vec3.fromValues(cur[6] - defX, cur[7] - defY, 0);
232
232
  vec3.transformMat4(c, c, localTransform);
233
- path = "".concat(cur[0]).concat(cur[1], ",").concat(cur[2], ",").concat(cur[3], ",").concat(cur[4], ",").concat(cur[5], ",").concat(c[0], ",").concat(c[1]);
233
+ path = "" + cur[0] + cur[1] + "," + cur[2] + "," + cur[3] + "," + cur[4] + "," + cur[5] + "," + c[0] + "," + c[1];
234
234
  }
235
235
 
236
236
  return prev += path;
package/es/utils/text.js CHANGED
@@ -7,7 +7,7 @@ export function toFontString(attributes) {
7
7
  fontVariant = attributes.fontVariant,
8
8
  fontWeight = attributes.fontWeight; // build canvas api font setting from individual components. Convert a numeric this.fontSize to px
9
9
 
10
- var fontSizeString = isNumber(fontSize) ? "".concat(fontSize, "px") : fontSize.toString(); // Clean-up fontFamily property by quoting each font name
10
+ var fontSizeString = isNumber(fontSize) ? fontSize + "px" : fontSize.toString(); // Clean-up fontFamily property by quoting each font name
11
11
  // this will support font names with spaces
12
12
  // @ts-ignore
13
13
 
@@ -18,11 +18,11 @@ export function toFontString(attributes) {
18
18
  var fontFamily_1 = fontFamilies[i].trim(); // Check if font already contains strings
19
19
 
20
20
  if (!/([\"\'])[^\'\"]+\1/.test(fontFamily_1) && genericFontFamilies.indexOf(fontFamily_1) < 0) {
21
- fontFamily_1 = "\"".concat(fontFamily_1, "\"");
21
+ fontFamily_1 = "\"" + fontFamily_1 + "\"";
22
22
  }
23
23
 
24
24
  fontFamilies[i] = fontFamily_1;
25
25
  }
26
26
 
27
- return "".concat(fontStyle, " ").concat(fontVariant, " ").concat(fontWeight, " ").concat(fontSizeString, " ").concat(fontFamilies.join(','));
27
+ return fontStyle + " " + fontVariant + " " + fontWeight + " " + fontSizeString + " " + fontFamilies.join(',');
28
28
  }
@@ -7,9 +7,7 @@ exports.AbstractRenderer = void 0;
7
7
 
8
8
  var _tslib = require("tslib");
9
9
 
10
- var AbstractRenderer =
11
- /** @class */
12
- function () {
10
+ var AbstractRenderer = function () {
13
11
  function AbstractRenderer(config) {
14
12
  this.plugins = [];
15
13
  this.config = (0, _tslib.__assign)({
package/lib/Canvas.js CHANGED
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.CanvasEvent = exports.Canvas = void 0;
6
+ exports.Canvas = exports.CanvasEvent = void 0;
7
7
 
8
8
  var _tslib = require("tslib");
9
9
 
@@ -54,9 +54,7 @@ exports.CanvasEvent = CanvasEvent;
54
54
  */
55
55
 
56
56
 
57
- var Canvas =
58
- /** @class */
59
- function (_super) {
57
+ var Canvas = function (_super) {
60
58
  (0, _tslib.__extends)(Canvas, _super);
61
59
 
62
60
  function Canvas(config) {
@@ -111,20 +109,18 @@ function (_super) {
111
109
 
112
110
 
113
111
  _this.devicePixelRatio = dpr;
114
- _this.requestAnimationFrame = requestAnimationFrame || _requestAnimationFramePolyfill.requestAnimationFrame.bind(globalThis);
115
- _this.cancelAnimationFrame = cancelAnimationFrame || _requestAnimationFramePolyfill.cancelAnimationFrame.bind(globalThis);
112
+ _this.requestAnimationFrame = requestAnimationFrame !== null && requestAnimationFrame !== void 0 ? requestAnimationFrame : _requestAnimationFramePolyfill.requestAnimationFrame.bind(globalThis);
113
+ _this.cancelAnimationFrame = cancelAnimationFrame !== null && cancelAnimationFrame !== void 0 ? cancelAnimationFrame : _requestAnimationFramePolyfill.cancelAnimationFrame.bind(globalThis);
116
114
  /**
117
115
  * limits query
118
116
  */
119
117
 
120
- _this.supportTouchEvent = supportTouchEvent || 'ontouchstart' in globalThis;
121
- _this.supportPointerEvent = supportPointerEvent || !!globalThis.PointerEvent;
122
-
123
- _this.isTouchEvent = isTouchEvent || function (event) {
118
+ _this.supportTouchEvent = supportTouchEvent !== null && supportTouchEvent !== void 0 ? supportTouchEvent : 'ontouchstart' in globalThis;
119
+ _this.supportPointerEvent = supportPointerEvent !== null && supportPointerEvent !== void 0 ? supportPointerEvent : !!globalThis.PointerEvent;
120
+ _this.isTouchEvent = isTouchEvent !== null && isTouchEvent !== void 0 ? isTouchEvent : function (event) {
124
121
  return _this.supportTouchEvent && event instanceof globalThis.TouchEvent;
125
122
  };
126
-
127
- _this.isMouseEvent = isMouseEvent || function (event) {
123
+ _this.isMouseEvent = isMouseEvent !== null && isMouseEvent !== void 0 ? isMouseEvent : function (event) {
128
124
  return !globalThis.MouseEvent || event instanceof globalThis.MouseEvent && (!_this.supportPointerEvent || !(event instanceof globalThis.PointerEvent));
129
125
  };
130
126
 
@@ -9,9 +9,7 @@ var _tslib = require("tslib");
9
9
 
10
10
  var _manaSyringe = require("mana-syringe");
11
11
 
12
- var DisplayObjectPool =
13
- /** @class */
14
- function () {
12
+ var DisplayObjectPool = function () {
15
13
  function DisplayObjectPool() {
16
14
  this.pool = {};
17
15
  }
@@ -1,9 +1,11 @@
1
1
  import { EventEmitter } from 'eventemitter3';
2
+ import type { vec2 } from 'gl-matrix';
2
3
  import { mat4, vec3 } from 'gl-matrix';
3
4
  import { Landmark } from './Landmark';
4
5
  import { Frustum } from '../shapes';
5
6
  import type { Canvas } from '../Canvas';
6
- export declare const DefaultCamera = "DefaultCamera";
7
+ import { Syringe } from 'mana-syringe';
8
+ export declare const DefaultCamera: Syringe.DefinedToken;
7
9
  export declare enum CAMERA_TYPE {
8
10
  ORBITING = "ORBITING",
9
11
  EXPLORING = "EXPLORING",
@@ -114,7 +116,6 @@ export declare class Camera extends EventEmitter {
114
116
  private projectionMatrixInverse;
115
117
  private jitteredProjectionMatrix;
116
118
  private view;
117
- private following;
118
119
  private type;
119
120
  private trackingMode;
120
121
  private projectionMode;
@@ -239,13 +240,17 @@ export declare class Camera extends EventEmitter {
239
240
  * 沿 n 轴移动,当距离视点远时移动速度较快,离视点越近速度越慢
240
241
  */
241
242
  dolly(value: number): this;
242
- createLandmark(name: string, params: {
243
- position: vec3;
244
- focalPoint: vec3;
243
+ createLandmark(name: string, params?: Partial<{
244
+ position: vec3 | vec2;
245
+ focalPoint: vec3 | vec2;
246
+ zoom?: number;
245
247
  roll?: number;
246
- }): Landmark;
248
+ }>): Landmark;
247
249
  setLandmark(name: string): this;
248
- gotoLandmark(name: string, duration?: number): void;
250
+ gotoLandmark(name: string | Landmark, options?: number | Partial<{
251
+ easing: string;
252
+ duration: number;
253
+ }>): void;
249
254
  /**
250
255
  * 根据相机矩阵重新计算各种相机参数
251
256
  */
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.DefaultCamera = exports.CameraEvent = exports.Camera = exports.CAMERA_TYPE = exports.CAMERA_TRACKING_MODE = exports.CAMERA_PROJECTION_MODE = void 0;
6
+ exports.Camera = exports.CameraEvent = exports.CAMERA_PROJECTION_MODE = exports.CAMERA_TRACKING_MODE = exports.CAMERA_TYPE = exports.DefaultCamera = void 0;
7
7
 
8
8
  var _tslib = require("tslib");
9
9
 
@@ -17,7 +17,14 @@ var _shapes = require("../shapes");
17
17
 
18
18
  var _math = require("../utils/math");
19
19
 
20
- var DefaultCamera = 'DefaultCamera';
20
+ var _animation = require("../utils/animation");
21
+
22
+ var _util = require("@antv/util");
23
+
24
+ var _manaSyringe = require("mana-syringe");
25
+
26
+ var DefaultCamera = _manaSyringe.Syringe.defineToken('DefaultCamera');
27
+
21
28
  exports.DefaultCamera = DefaultCamera;
22
29
  var CAMERA_TYPE;
23
30
  exports.CAMERA_TYPE = CAMERA_TYPE;
@@ -61,9 +68,7 @@ var RAD_2_DEG = 180 / Math.PI;
61
68
  * 4. 移动到 Landmark,具有平滑的动画效果,其间禁止其他用户交互
62
69
  */
63
70
 
64
- var Camera =
65
- /** @class */
66
- function (_super) {
71
+ var Camera = function (_super) {
67
72
  (0, _tslib.__extends)(Camera, _super);
68
73
 
69
74
  function Camera() {
@@ -157,8 +162,8 @@ function (_super) {
157
162
  _this.aspect = 1;
158
163
  _this.projectionMatrix = _glMatrix.mat4.create();
159
164
  _this.projectionMatrixInverse = _glMatrix.mat4.create();
160
- _this.jitteredProjectionMatrix = undefined;
161
- _this.following = undefined;
165
+ _this.jitteredProjectionMatrix = undefined; // private following = undefined;
166
+
162
167
  _this.type = CAMERA_TYPE.EXPLORING;
163
168
  _this.trackingMode = CAMERA_TRACKING_MODE.DEFAULT;
164
169
  _this.projectionMode = CAMERA_PROJECTION_MODE.PERSPECTIVE;
@@ -775,12 +780,24 @@ function (_super) {
775
780
  };
776
781
 
777
782
  Camera.prototype.createLandmark = function (name, params) {
783
+ if (params === void 0) {
784
+ params = {};
785
+ }
786
+
787
+ var position = params.position,
788
+ focalPoint = params.focalPoint,
789
+ roll = params.roll,
790
+ zoom = params.zoom;
778
791
  var camera = this.clone();
779
- camera.setPosition(params.position);
780
- camera.setFocalPoint(params.focalPoint);
792
+ camera.setPosition(_glMatrix.vec3.fromValues(position[0], position[1], position[2] || this.position[2]));
793
+ camera.setFocalPoint(_glMatrix.vec3.fromValues(focalPoint[0], focalPoint[1], focalPoint[2] || this.focalPoint[2]));
781
794
 
782
- if (params.roll !== undefined) {
783
- camera.setRoll(params.roll);
795
+ if (!(0, _util.isUndefined)(roll)) {
796
+ camera.setRoll(roll);
797
+ }
798
+
799
+ if (!(0, _util.isUndefined)(zoom)) {
800
+ camera.setZoom(zoom);
784
801
  }
785
802
 
786
803
  var landmark = new _Landmark.Landmark(name, camera);
@@ -794,19 +811,29 @@ function (_super) {
794
811
  return this;
795
812
  };
796
813
 
797
- Camera.prototype.gotoLandmark = function (name, duration) {
814
+ Camera.prototype.gotoLandmark = function (name, options) {
798
815
  var _this = this;
799
816
 
800
- if (duration === void 0) {
801
- duration = 1000;
817
+ if (options === void 0) {
818
+ options = {};
802
819
  }
803
820
 
804
- var landmark = this.landmarks.find(function (l) {
821
+ var landmark = (0, _util.isString)(name) ? this.landmarks.find(function (l) {
805
822
  return l.name === name;
806
- });
823
+ }) : name;
807
824
 
808
825
  if (landmark) {
809
- if (duration === 0) {
826
+ var _a = (0, _util.isNumber)(options) ? {
827
+ duration: options
828
+ } : options,
829
+ _b = _a.easing,
830
+ easing = _b === void 0 ? 'ease' : _b,
831
+ _c = _a.duration,
832
+ duration_1 = _c === void 0 ? 1000 : _c;
833
+
834
+ var epsilon_1 = 0.01;
835
+
836
+ if (duration_1 === 0) {
810
837
  landmark.retrieve(this);
811
838
  return;
812
839
  }
@@ -819,7 +846,9 @@ function (_super) {
819
846
 
820
847
  var destPosition_1 = landmark.getPosition();
821
848
  var destFocalPoint_1 = landmark.getFocalPoint();
849
+ var destZoom_1 = landmark.getZoom();
822
850
  var destRoll_1 = landmark.getRoll();
851
+ var easingFunction_1 = (0, _animation.parseEasingFunction)(easing);
823
852
  var timeStart_1;
824
853
 
825
854
  var animate_1 = function animate_1(timestamp) {
@@ -827,14 +856,15 @@ function (_super) {
827
856
  timeStart_1 = timestamp;
828
857
  }
829
858
 
830
- var elapsed = timestamp - timeStart_1; // TODO: use better ease function
859
+ var elapsed = timestamp - timeStart_1; // use the same ease function in animatio system
831
860
 
832
- var t = (1 - Math.cos(elapsed / duration * Math.PI)) / 2;
861
+ var t = easingFunction_1(elapsed / duration_1);
833
862
 
834
863
  var interFocalPoint = _glMatrix.vec3.create();
835
864
 
836
865
  var interPosition = _glMatrix.vec3.create();
837
866
 
867
+ var interZoom = 1;
838
868
  var interRoll = 0;
839
869
 
840
870
  _glMatrix.vec3.lerp(interFocalPoint, _this.focalPoint, destFocalPoint_1, t);
@@ -842,6 +872,7 @@ function (_super) {
842
872
  _glMatrix.vec3.lerp(interPosition, _this.position, destPosition_1, t);
843
873
 
844
874
  interRoll = _this.roll * (1 - t) + destRoll_1 * t;
875
+ interZoom = _this.zoom * (1 - t) + destZoom_1 * t;
845
876
 
846
877
  _this.setFocalPoint(interFocalPoint);
847
878
 
@@ -849,19 +880,22 @@ function (_super) {
849
880
 
850
881
  _this.setRoll(interRoll);
851
882
 
883
+ _this.setZoom(interZoom);
884
+
852
885
  _this.computeMatrix();
853
886
 
854
887
  _this.triggerUpdate();
855
888
 
856
889
  var dist = _glMatrix.vec3.dist(interFocalPoint, destFocalPoint_1) + _glMatrix.vec3.dist(interPosition, destPosition_1);
857
890
 
858
- if (dist > 0.01) {//
859
- } else {
860
- _this.setFocalPoint(interFocalPoint);
891
+ if (dist <= epsilon_1) {
892
+ _this.setFocalPoint(destFocalPoint_1);
893
+
894
+ _this.setPosition(destPosition_1);
861
895
 
862
- _this.setPosition(interPosition);
896
+ _this.setRoll(destRoll_1);
863
897
 
864
- _this.setRoll(interRoll);
898
+ _this.setZoom(destZoom_1);
865
899
 
866
900
  _this.computeMatrix(); // this.interactor.connect();
867
901
 
@@ -869,7 +903,7 @@ function (_super) {
869
903
  return;
870
904
  }
871
905
 
872
- if (elapsed < duration) {
906
+ if (elapsed < duration_1) {
873
907
  _this.landmarkAnimationID = _this.canvas.requestAnimationFrame(animate_1);
874
908
  }
875
909
  };
@@ -20,9 +20,11 @@ export declare class Landmark {
20
20
  private relAzimuth;
21
21
  private relElevation;
22
22
  private relRoll;
23
+ private zoom;
23
24
  constructor(name: string, c: Camera);
24
25
  getPosition(): vec3;
25
26
  getFocalPoint(): vec3;
26
27
  getRoll(): number;
28
+ getZoom(): number;
27
29
  retrieve(c: Camera): void;
28
30
  }
@@ -10,10 +10,7 @@ var _glMatrix = require("gl-matrix");
10
10
  /**
11
11
  * 保存相机状态,便于后续在多个 Landmark 间移动
12
12
  */
13
- var Landmark =
14
- /** @class */
15
- function () {
16
- // private zoom = 1;
13
+ var Landmark = function () {
17
14
  function Landmark(name, c) {
18
15
  this.azimuth = 0;
19
16
  this.elevation = 0;
@@ -21,6 +18,7 @@ function () {
21
18
  this.relAzimuth = 0;
22
19
  this.relElevation = 0;
23
20
  this.relRoll = 0;
21
+ this.zoom = 1;
24
22
  this.name = name;
25
23
  this.matrix = _glMatrix.mat4.clone(c.matrix);
26
24
  this.right = _glMatrix.vec3.clone(c.right);
@@ -36,7 +34,8 @@ function () {
36
34
  this.relElevation = c.relElevation;
37
35
  this.relRoll = c.relRoll;
38
36
  this.dollyingStep = c.dollyingStep;
39
- this.distance = c.distance; // this.zoom = c.zoom;
37
+ this.distance = c.distance;
38
+ this.zoom = c.zoom;
40
39
  }
41
40
 
42
41
  Landmark.prototype.getPosition = function () {
@@ -51,6 +50,10 @@ function () {
51
50
  return this.roll;
52
51
  };
53
52
 
53
+ Landmark.prototype.getZoom = function () {
54
+ return this.zoom;
55
+ };
56
+
54
57
  Landmark.prototype.retrieve = function (c) {
55
58
  c.matrix = _glMatrix.mat4.copy(c.matrix, this.matrix);
56
59
  c.right = _glMatrix.vec3.copy(c.right, this.right);
@@ -66,7 +69,8 @@ function () {
66
69
  c.relElevation = this.relElevation;
67
70
  c.relRoll = this.relRoll;
68
71
  c.dollyingStep = this.dollyingStep;
69
- c.distance = this.distance; // c.zoom = this.zoom;
72
+ c.distance = this.distance;
73
+ c.zoom = this.zoom;
70
74
  };
71
75
 
72
76
  return Landmark;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.Strategy = exports.Cullable = void 0;
6
+ exports.Cullable = exports.Strategy = void 0;
7
7
 
8
8
  /**
9
9
  * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#changing-mesh-culling-strategy
@@ -15,9 +15,7 @@ exports.Strategy = Strategy;
15
15
  Strategy[Strategy["Standard"] = 0] = "Standard";
16
16
  })(Strategy || (exports.Strategy = Strategy = {}));
17
17
 
18
- var Cullable =
19
- /** @class */
20
- function () {
18
+ var Cullable = function () {
21
19
  function Cullable() {
22
20
  this.strategy = Strategy.Standard;
23
21
  this.visibilityPlaneMask = -1;
@@ -5,9 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.Geometry = void 0;
7
7
 
8
- var Geometry =
9
- /** @class */
10
- function () {
8
+ var Geometry = function () {
11
9
  function Geometry() {}
12
10
 
13
11
  Geometry.tag = 'c-geometry';
@@ -5,9 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.Renderable = void 0;
7
7
 
8
- var Renderable =
9
- /** @class */
10
- function () {
8
+ var Renderable = function () {
11
9
  function Renderable() {
12
10
  this.boundsDirty = true;
13
11
  this.renderBoundsDirty = true;
@@ -5,9 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.Sortable = void 0;
7
7
 
8
- var Sortable =
9
- /** @class */
10
- function () {
8
+ var Sortable = function () {
11
9
  function Sortable() {
12
10
  /**
13
11
  * need to re-sort
@@ -10,9 +10,7 @@ var _glMatrix = require("gl-matrix");
10
10
  /**
11
11
  * do RTS transformation for 2D/3D
12
12
  */
13
- var Transform =
14
- /** @class */
15
- function () {
13
+ var Transform = function () {
16
14
  function Transform() {
17
15
  this.dirtyFlag = false;
18
16
  this.localDirtyFlag = false;