@antv/g 5.0.1 → 5.0.5
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.
- package/LICENSE +21 -0
- package/dist/index.umd.js +2 -2
- package/es/AbstractRenderer.d.ts +7 -7
- package/es/Canvas.d.ts +15 -5
- package/es/Canvas.js +10 -5
- package/es/camera/Camera.js +3 -5
- package/es/components/Geometry.d.ts +1 -1
- package/es/components/Renderable.d.ts +1 -1
- package/es/display-objects/CustomElement.d.ts +7 -8
- package/es/display-objects/CustomElement.js +24 -11
- package/es/display-objects/DisplayObject.d.ts +5 -7
- package/es/display-objects/DisplayObject.js +20 -12
- package/es/display-objects/Group.d.ts +1 -1
- package/es/display-objects/HTML.d.ts +1 -1
- package/es/display-objects/Image.d.ts +1 -1
- package/es/display-objects/Path.d.ts +1 -1
- package/es/display-objects/Polygon.d.ts +1 -1
- package/es/display-objects/Polyline.d.ts +1 -1
- package/es/display-objects/Text.d.ts +1 -1
- package/es/display-objects/Text.js +1 -1
- package/es/dom/Animation.js +9 -4
- package/es/dom/AnimationEffectTiming.d.ts +0 -1
- package/es/dom/AnimationTimeline.js +2 -1
- package/es/dom/CustomElementRegistry.d.ts +1 -1
- package/es/dom/CustomEvent.js +2 -1
- package/es/dom/Document.d.ts +3 -3
- package/es/dom/Document.js +13 -6
- package/es/dom/Element.d.ts +11 -12
- package/es/dom/Element.js +12 -8
- package/es/dom/EventTarget.js +1 -0
- package/es/dom/FederatedEvent.d.ts +1 -1
- package/es/dom/KeyframeEffect.js +1 -1
- package/es/dom/Node.d.ts +10 -10
- package/es/dom/Node.js +11 -5
- package/es/dom/interfaces.d.ts +63 -63
- package/es/global-module.d.ts +4 -0
- package/es/global-module.js +57 -69
- package/es/plugins/CullingPlugin.d.ts +3 -3
- package/es/plugins/DirtyCheckPlugin.d.ts +1 -1
- package/es/plugins/EventPlugin.d.ts +2 -1
- package/es/plugins/FrustumCullingStrategy.d.ts +1 -2
- package/es/plugins/FrustumCullingStrategy.js +31 -32
- package/es/plugins/PrepareRendererPlugin.d.ts +1 -1
- package/es/plugins/PrepareRendererPlugin.js +7 -20
- package/es/property-handlers/aabb.js +16 -19
- package/es/property-handlers/anchor.d.ts +2 -1
- package/es/property-handlers/anchor.js +2 -2
- package/es/property-handlers/clipPath.js +2 -2
- package/es/property-handlers/color.d.ts +3 -4
- package/es/property-handlers/color.js +2 -2
- package/es/property-handlers/filter.d.ts +3 -4
- package/es/property-handlers/filter.js +2 -2
- package/es/property-handlers/interfaces.d.ts +1 -1
- package/es/property-handlers/lineDash.d.ts +1 -2
- package/es/property-handlers/lineDash.js +1 -1
- package/es/property-handlers/path.d.ts +2 -3
- package/es/property-handlers/path.js +2 -2
- package/es/property-handlers/points.d.ts +1 -2
- package/es/property-handlers/points.js +1 -1
- package/es/property-handlers/transform.d.ts +1 -1
- package/es/property-handlers/transform.js +0 -5
- package/es/services/ContextService.d.ts +8 -8
- package/es/services/EventService.d.ts +2 -2
- package/es/services/RenderingContext.d.ts +2 -2
- package/es/services/RenderingService.d.ts +23 -18
- package/es/services/RenderingService.js +18 -4
- package/es/services/SceneGraphSelector.d.ts +5 -5
- package/es/services/SceneGraphSelector.js +3 -2
- package/es/services/SceneGraphService.d.ts +36 -34
- package/es/services/SceneGraphService.js +33 -4
- package/es/services/aabb/PathUpdater.d.ts +1 -2
- package/es/services/aabb/PathUpdater.js +1 -1
- package/es/services/aabb/interfaces.d.ts +1 -1
- package/es/services/text/index.js +1 -1
- package/es/shapes/AABB.d.ts +3 -2
- package/es/shapes/Frustum.d.ts +1 -1
- package/es/shapes/Polygon.d.ts +1 -1
- package/es/shapes/Ray.d.ts +3 -3
- package/es/types.d.ts +1 -2
- package/es/utils/custom-easing.d.ts +3 -5
- package/es/utils/custom-easing.js +2 -1
- package/es/utils/event.d.ts +1 -1
- package/es/utils/interpolation.js +16 -16
- package/es/utils/math.d.ts +2 -1
- package/es/utils/math.js +1 -2
- package/es/utils/path.d.ts +1 -1
- package/es/utils/path.js +4 -7
- package/es/utils/raf.js +2 -1
- package/lib/AbstractRenderer.d.ts +7 -7
- package/lib/Canvas.d.ts +15 -5
- package/lib/Canvas.js +10 -5
- package/lib/camera/Camera.js +4 -5
- package/lib/components/Geometry.d.ts +1 -1
- package/lib/components/Renderable.d.ts +1 -1
- package/lib/display-objects/CustomElement.d.ts +7 -8
- package/lib/display-objects/CustomElement.js +24 -11
- package/lib/display-objects/DisplayObject.d.ts +5 -7
- package/lib/display-objects/DisplayObject.js +19 -11
- package/lib/display-objects/Group.d.ts +1 -1
- package/lib/display-objects/HTML.d.ts +1 -1
- package/lib/display-objects/Image.d.ts +1 -1
- package/lib/display-objects/Path.d.ts +1 -1
- package/lib/display-objects/Polygon.d.ts +1 -1
- package/lib/display-objects/Polyline.d.ts +1 -1
- package/lib/display-objects/Text.d.ts +1 -1
- package/lib/display-objects/Text.js +1 -1
- package/lib/dom/Animation.js +9 -4
- package/lib/dom/AnimationEffectTiming.d.ts +0 -1
- package/lib/dom/AnimationTimeline.js +2 -1
- package/lib/dom/CustomElementRegistry.d.ts +1 -1
- package/lib/dom/CustomEvent.js +1 -1
- package/lib/dom/Document.d.ts +3 -3
- package/lib/dom/Document.js +13 -6
- package/lib/dom/Element.d.ts +11 -12
- package/lib/dom/Element.js +12 -8
- package/lib/dom/EventTarget.js +1 -0
- package/lib/dom/FederatedEvent.d.ts +1 -1
- package/lib/dom/KeyframeEffect.js +1 -1
- package/lib/dom/Node.d.ts +10 -10
- package/lib/dom/Node.js +11 -5
- package/lib/dom/interfaces.d.ts +63 -63
- package/lib/global-module.d.ts +4 -0
- package/lib/global-module.js +57 -69
- package/lib/plugins/CullingPlugin.d.ts +3 -3
- package/lib/plugins/DirtyCheckPlugin.d.ts +1 -1
- package/lib/plugins/EventPlugin.d.ts +2 -1
- package/lib/plugins/FrustumCullingStrategy.d.ts +1 -2
- package/lib/plugins/FrustumCullingStrategy.js +28 -30
- package/lib/plugins/PrepareRendererPlugin.d.ts +1 -1
- package/lib/plugins/PrepareRendererPlugin.js +6 -19
- package/lib/property-handlers/aabb.js +15 -19
- package/lib/property-handlers/anchor.d.ts +2 -1
- package/lib/property-handlers/anchor.js +2 -2
- package/lib/property-handlers/clipPath.js +2 -2
- package/lib/property-handlers/color.d.ts +3 -4
- package/lib/property-handlers/color.js +2 -2
- package/lib/property-handlers/filter.d.ts +3 -4
- package/lib/property-handlers/filter.js +2 -2
- package/lib/property-handlers/interfaces.d.ts +1 -1
- package/lib/property-handlers/lineDash.d.ts +1 -2
- package/lib/property-handlers/lineDash.js +1 -1
- package/lib/property-handlers/path.d.ts +2 -3
- package/lib/property-handlers/path.js +2 -2
- package/lib/property-handlers/points.d.ts +1 -2
- package/lib/property-handlers/points.js +1 -1
- package/lib/property-handlers/transform.d.ts +1 -1
- package/lib/property-handlers/transform.js +0 -4
- package/lib/services/ContextService.d.ts +8 -8
- package/lib/services/EventService.d.ts +2 -2
- package/lib/services/RenderingContext.d.ts +2 -2
- package/lib/services/RenderingService.d.ts +23 -18
- package/lib/services/RenderingService.js +18 -4
- package/lib/services/SceneGraphSelector.d.ts +5 -5
- package/lib/services/SceneGraphSelector.js +3 -2
- package/lib/services/SceneGraphService.d.ts +36 -34
- package/lib/services/SceneGraphService.js +35 -4
- package/lib/services/aabb/PathUpdater.d.ts +1 -2
- package/lib/services/aabb/PathUpdater.js +1 -1
- package/lib/services/aabb/interfaces.d.ts +1 -1
- package/lib/services/text/index.js +1 -1
- package/lib/shapes/AABB.d.ts +3 -2
- package/lib/shapes/Frustum.d.ts +1 -1
- package/lib/shapes/Polygon.d.ts +1 -1
- package/lib/shapes/Ray.d.ts +3 -3
- package/lib/types.d.ts +1 -2
- package/lib/utils/custom-easing.d.ts +3 -5
- package/lib/utils/custom-easing.js +2 -1
- package/lib/utils/event.d.ts +1 -1
- package/lib/utils/interpolation.js +13 -18
- package/lib/utils/math.d.ts +2 -1
- package/lib/utils/math.js +1 -2
- package/lib/utils/path.d.ts +2 -2
- package/lib/utils/path.js +4 -7
- package/lib/utils/raf.js +2 -1
- package/package.json +6 -6
- package/lib/dom/__tests__/utils/easing.d.ts +0 -14
- package/lib/dom/__tests__/utils/keyframe.d.ts +0 -38
|
@@ -1,42 +1,44 @@
|
|
|
1
|
-
import { Transform } from '../components';
|
|
2
|
-
import {
|
|
1
|
+
import type { Transform } from '../components';
|
|
2
|
+
import type { vec2 } from 'gl-matrix';
|
|
3
|
+
import { mat4, quat, vec3 } from 'gl-matrix';
|
|
3
4
|
import { AABB, Rectangle } from '../shapes';
|
|
4
5
|
import type { IElement, INode, IParentNode } from '../dom/interfaces';
|
|
5
6
|
export declare function sortByZIndex(o1: IElement, o2: IElement): number;
|
|
7
|
+
export declare function dirtifyToRoot(element: INode, affectChildren?: boolean): void;
|
|
6
8
|
export declare const SceneGraphService = "SceneGraphService";
|
|
7
9
|
export interface SceneGraphService {
|
|
8
|
-
matches<T extends IElement>(query: string, root: T)
|
|
9
|
-
querySelector<R extends IElement, T extends IElement>(query: string, root: R)
|
|
10
|
-
querySelectorAll<R extends IElement, T extends IElement>(query: string, root: R)
|
|
11
|
-
attach<C extends INode, P extends INode & IParentNode>(child: C, parent: P, index?: number)
|
|
12
|
-
detach<C extends INode>(child: C)
|
|
13
|
-
sort(object1: IElement, object2: IElement)
|
|
14
|
-
getOrigin(element: INode)
|
|
15
|
-
setOrigin(element: INode, origin: vec3 | number, y?: number, z?: number)
|
|
16
|
-
setPosition(element: INode, position: vec3 | vec2)
|
|
17
|
-
setLocalPosition(element: INode, position: vec3 | vec2)
|
|
18
|
-
scaleLocal(element: INode, scaling: vec3 | vec2)
|
|
19
|
-
setLocalScale(element: INode, scaling: vec3 | vec2)
|
|
20
|
-
getLocalScale(element: INode)
|
|
21
|
-
getScale(element: INode)
|
|
22
|
-
translate(element: INode, translation: vec3 | number, y?: number, z?: number)
|
|
23
|
-
translateLocal(element: INode, translation: vec3 | number, y?: number, z?: number)
|
|
24
|
-
getPosition(element: INode)
|
|
25
|
-
getLocalPosition(element: INode)
|
|
26
|
-
setEulerAngles(element: INode, degrees: vec3 | number, y?: number, z?: number)
|
|
27
|
-
setLocalEulerAngles(element: INode, degrees: vec3 | number, y?: number, z?: number)
|
|
28
|
-
rotateLocal(element: INode, degrees: vec3 | number, y?: number, z?: number)
|
|
29
|
-
rotate(element: INode, degrees: vec3 | number, y?: number, z?: number)
|
|
30
|
-
getRotation(element: INode)
|
|
31
|
-
getLocalRotation(element: INode)
|
|
32
|
-
getWorldTransform(element: INode, transform?: Transform)
|
|
33
|
-
getLocalTransform(element: INode, transform?: Transform)
|
|
34
|
-
resetLocalTransform(element: INode)
|
|
35
|
-
getBounds(element: INode, render?: boolean)
|
|
36
|
-
getLocalBounds(element: INode, render?: boolean)
|
|
37
|
-
getGeometryBounds(element: INode, render?: boolean)
|
|
38
|
-
getBoundingClientRect(element: INode)
|
|
39
|
-
syncHierarchy(element: INode)
|
|
10
|
+
matches: <T extends IElement>(query: string, root: T) => boolean;
|
|
11
|
+
querySelector: <R extends IElement, T extends IElement>(query: string, root: R) => T | null;
|
|
12
|
+
querySelectorAll: <R extends IElement, T extends IElement>(query: string, root: R) => T[];
|
|
13
|
+
attach: <C extends INode, P extends INode & IParentNode>(child: C, parent: P, index?: number) => void;
|
|
14
|
+
detach: <C extends INode>(child: C) => void;
|
|
15
|
+
sort: (object1: IElement, object2: IElement) => number;
|
|
16
|
+
getOrigin: (element: INode) => vec3;
|
|
17
|
+
setOrigin: (element: INode, origin: vec3 | number, y?: number, z?: number) => void;
|
|
18
|
+
setPosition: (element: INode, position: vec3 | vec2) => void;
|
|
19
|
+
setLocalPosition: (element: INode, position: vec3 | vec2) => void;
|
|
20
|
+
scaleLocal: (element: INode, scaling: vec3 | vec2) => void;
|
|
21
|
+
setLocalScale: (element: INode, scaling: vec3 | vec2) => void;
|
|
22
|
+
getLocalScale: (element: INode) => vec3;
|
|
23
|
+
getScale: (element: INode) => vec3;
|
|
24
|
+
translate: (element: INode, translation: vec3 | number, y?: number, z?: number) => void;
|
|
25
|
+
translateLocal: (element: INode, translation: vec3 | number, y?: number, z?: number) => void;
|
|
26
|
+
getPosition: (element: INode) => vec3;
|
|
27
|
+
getLocalPosition: (element: INode) => vec3;
|
|
28
|
+
setEulerAngles: (element: INode, degrees: vec3 | number, y?: number, z?: number) => void;
|
|
29
|
+
setLocalEulerAngles: (element: INode, degrees: vec3 | number, y?: number, z?: number) => void;
|
|
30
|
+
rotateLocal: (element: INode, degrees: vec3 | number, y?: number, z?: number) => void;
|
|
31
|
+
rotate: (element: INode, degrees: vec3 | number, y?: number, z?: number) => void;
|
|
32
|
+
getRotation: (element: INode) => quat;
|
|
33
|
+
getLocalRotation: (element: INode) => quat;
|
|
34
|
+
getWorldTransform: (element: INode, transform?: Transform) => mat4;
|
|
35
|
+
getLocalTransform: (element: INode, transform?: Transform) => mat4;
|
|
36
|
+
resetLocalTransform: (element: INode) => void;
|
|
37
|
+
getBounds: (element: INode, render?: boolean) => AABB | null;
|
|
38
|
+
getLocalBounds: (element: INode, render?: boolean) => AABB | null;
|
|
39
|
+
getGeometryBounds: (element: INode, render?: boolean) => AABB | null;
|
|
40
|
+
getBoundingClientRect: (element: INode) => Rectangle;
|
|
41
|
+
syncHierarchy: (element: INode) => void;
|
|
40
42
|
}
|
|
41
43
|
/**
|
|
42
44
|
* update transform in scene graph
|
|
@@ -21,6 +21,29 @@ export function sortByZIndex(o1, o2) {
|
|
|
21
21
|
|
|
22
22
|
return zIndex1 - zIndex2;
|
|
23
23
|
}
|
|
24
|
+
export function dirtifyToRoot(element, affectChildren) {
|
|
25
|
+
if (affectChildren === void 0) {
|
|
26
|
+
affectChildren = false;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
var p = element;
|
|
30
|
+
|
|
31
|
+
while (p) {
|
|
32
|
+
var renderable = p.renderable;
|
|
33
|
+
|
|
34
|
+
if (renderable) {
|
|
35
|
+
renderable.renderBoundsDirty = true;
|
|
36
|
+
renderable.boundsDirty = true;
|
|
37
|
+
renderable.dirty = true;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
p = p.parentNode;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
element.emit(ElementEvent.BOUNDS_CHANGED, {
|
|
44
|
+
affectChildren: affectChildren
|
|
45
|
+
});
|
|
46
|
+
}
|
|
24
47
|
export var SceneGraphService = 'SceneGraphService';
|
|
25
48
|
/**
|
|
26
49
|
* update transform in scene graph
|
|
@@ -497,9 +520,7 @@ function () {
|
|
|
497
520
|
}
|
|
498
521
|
|
|
499
522
|
this.dirtifyWorldInternal(element, transform);
|
|
500
|
-
element
|
|
501
|
-
affectChildren: true
|
|
502
|
-
});
|
|
523
|
+
dirtifyToRoot(element, true);
|
|
503
524
|
};
|
|
504
525
|
|
|
505
526
|
DefaultSceneGraphService.prototype.getPosition = function (element) {
|
|
@@ -733,7 +754,15 @@ function () {
|
|
|
733
754
|
if (!childTransform.dirtyFlag) {
|
|
734
755
|
_this.dirtifyWorldInternal(child, childTransform);
|
|
735
756
|
}
|
|
736
|
-
});
|
|
757
|
+
});
|
|
758
|
+
var renderable = element.renderable;
|
|
759
|
+
|
|
760
|
+
if (renderable) {
|
|
761
|
+
renderable.renderBoundsDirty = true;
|
|
762
|
+
renderable.boundsDirty = true;
|
|
763
|
+
renderable.dirty = true;
|
|
764
|
+
} // model matrix changed
|
|
765
|
+
|
|
737
766
|
|
|
738
767
|
element.emit(ElementEvent.ATTRIBUTE_CHANGED, {
|
|
739
768
|
attributeName: 'modelMatrix',
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { GeometryAABBUpdater } from './interfaces';
|
|
2
|
-
import type { DisplayObject } from '../../display-objects/DisplayObject';
|
|
3
2
|
import type { ParsedBaseStyleProps } from '../../types';
|
|
4
3
|
export declare class PathUpdater implements GeometryAABBUpdater<ParsedBaseStyleProps> {
|
|
5
|
-
update(parsedStyle: ParsedBaseStyleProps
|
|
4
|
+
update(parsedStyle: ParsedBaseStyleProps): {
|
|
6
5
|
width: number;
|
|
7
6
|
height: number;
|
|
8
7
|
x: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DisplayObject } from '../../display-objects/DisplayObject';
|
|
1
|
+
import type { DisplayObject } from '../../display-objects/DisplayObject';
|
|
2
2
|
import type { ParsedBaseStyleProps } from '../../types';
|
|
3
3
|
export declare const GeometryUpdaterFactory = "GeometryUpdaterFactory";
|
|
4
4
|
export declare const GeometryAABBUpdater = "GeometryAABBGenerator";
|
package/es/shapes/AABB.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { mat4
|
|
2
|
-
import {
|
|
1
|
+
import type { mat4 } from 'gl-matrix';
|
|
2
|
+
import { vec3 } from 'gl-matrix';
|
|
3
|
+
import type { Plane } from './Plane';
|
|
3
4
|
/**
|
|
4
5
|
* Axis-Aligned Bounding Box
|
|
5
6
|
* 为了便于后续 Frustum Culling,通过查找表定义 p-vertex 和 n-vertex
|
package/es/shapes/Frustum.d.ts
CHANGED
package/es/shapes/Polygon.d.ts
CHANGED
package/es/shapes/Ray.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { vec3 } from 'gl-matrix';
|
|
2
|
-
import { AABB } from './AABB';
|
|
3
|
-
import { BoundingSphere } from './BoundingSphere';
|
|
4
|
-
import { Plane } from './Plane';
|
|
2
|
+
import type { AABB } from './AABB';
|
|
3
|
+
import type { BoundingSphere } from './BoundingSphere';
|
|
4
|
+
import type { Plane } from './Plane';
|
|
5
5
|
/**
|
|
6
6
|
* 包含求交方法:
|
|
7
7
|
* * intersectsShape(Shape, intersection) 返回交点和求交结果
|
package/es/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { vec2, vec3 } from 'gl-matrix';
|
|
2
|
-
import { ParsedPathStyleProps, ParsedPolylineStyleProps } from './display-objects';
|
|
2
|
+
import type { ParsedPathStyleProps, ParsedPolylineStyleProps } from './display-objects';
|
|
3
3
|
import type { DisplayObject } from './display-objects';
|
|
4
4
|
import type { ParsedColorStyleProperty } from './property-handlers';
|
|
5
5
|
import type { IRenderer } from './AbstractRenderer';
|
|
@@ -192,7 +192,6 @@ export interface CanvasConfig {
|
|
|
192
192
|
cursor?: Cursor;
|
|
193
193
|
[key: string]: any;
|
|
194
194
|
}
|
|
195
|
-
export declare type ChangeType = 'changeSize' | 'add' | 'sort' | 'clear' | 'attr' | 'show' | 'hide' | 'zIndex' | 'remove' | 'matrix' | 'clip';
|
|
196
195
|
declare type A = ['a' | 'A', number, number, number, number, number, number, number];
|
|
197
196
|
declare type C = ['c' | 'C', number, number, number, number, number, number];
|
|
198
197
|
declare type O = ['o' | 'O', number, number];
|
|
@@ -4,7 +4,7 @@ export declare const limit: (value: number, min: number, max: number) => number;
|
|
|
4
4
|
* The format to use when defining custom easing functions
|
|
5
5
|
*/
|
|
6
6
|
export declare type TypeEasingFunction = (t: number, params?: (string | number)[], duration?: number) => number;
|
|
7
|
-
export declare type TypeColor = string | number |
|
|
7
|
+
export declare type TypeColor = string | number | (string | number)[];
|
|
8
8
|
export declare type TypeRGBAFunction = (color: TypeColor) => number[];
|
|
9
9
|
/**
|
|
10
10
|
Easing Functions from anime.js, they are tried and true, so, its better to use them instead of other alternatives
|
|
@@ -56,9 +56,7 @@ export declare const EaseOutIn: (ease: TypeEasingFunction) => TypeEasingFunction
|
|
|
56
56
|
/**
|
|
57
57
|
* The default list of easing functions, do note this is different from {@link EASING}
|
|
58
58
|
*/
|
|
59
|
-
export declare const EasingFunctions:
|
|
60
|
-
[key: string]: TypeEasingFunction;
|
|
61
|
-
};
|
|
59
|
+
export declare const EasingFunctions: Record<string, TypeEasingFunction>;
|
|
62
60
|
/**
|
|
63
61
|
* Convert string easing to their proper form
|
|
64
62
|
*/
|
|
@@ -72,4 +70,4 @@ export declare const registerEasingFunction: (key: string, fn: TypeEasingFunctio
|
|
|
72
70
|
/**
|
|
73
71
|
* Allows you to register multiple new easing functions
|
|
74
72
|
*/
|
|
75
|
-
export declare const registerEasingFunctions: (...obj:
|
|
73
|
+
export declare const registerEasingFunctions: (...obj: (typeof EasingFunctions)[]) => void;
|
|
@@ -134,7 +134,8 @@ export var getEasingDuration = function getEasingDuration(easing) {
|
|
|
134
134
|
easing = 'spring';
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
if (EasingDurationCache.has(easing)) return EasingDurationCache.get(easing);
|
|
137
|
+
if (EasingDurationCache.has(easing)) return EasingDurationCache.get(easing); // eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
138
|
+
|
|
138
139
|
var easingFunction = typeof easing == 'function' ? easing : getEasingFunction(easing);
|
|
139
140
|
var params = typeof easing == 'function' ? [] : parseEasingParameters(easing);
|
|
140
141
|
var frame = 1 / 6;
|
package/es/utils/event.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { __read, __spreadArray } from "tslib";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { stylePropertyMergerFactory, stylePropertyParserFactory } from '../global-module'; // import {
|
|
3
|
+
// StylePropertyMergerFactory,
|
|
4
|
+
// StylePropertyParserFactory,
|
|
5
|
+
// } from '../property-handlers/interfaces';
|
|
6
|
+
|
|
4
7
|
import { parseEasingFunction } from './animation';
|
|
5
8
|
export function convertEffectInput(keyframes, timing, target) {
|
|
6
9
|
var propertySpecificKeyframeGroups = makePropertySpecificKeyframeGroups(keyframes, timing);
|
|
@@ -104,11 +107,11 @@ function makeInterpolations(propertySpecificKeyframeGroups, target) {
|
|
|
104
107
|
|
|
105
108
|
function propertyInterpolation(property, left, right, target) {
|
|
106
109
|
var parsedLeft = left;
|
|
107
|
-
var parsedRight = right;
|
|
108
|
-
|
|
109
|
-
var parser =
|
|
110
|
-
|
|
111
|
-
var merger =
|
|
110
|
+
var parsedRight = right; // const parserFactory = globalContainer.get<StylePropertyParserFactory>(StylePropertyParserFactory);
|
|
111
|
+
|
|
112
|
+
var parser = stylePropertyParserFactory[property]; // const mergerFactory = globalContainer.get<StylePropertyMergerFactory>(StylePropertyMergerFactory);
|
|
113
|
+
|
|
114
|
+
var merger = stylePropertyMergerFactory[property]; // if (left == 'initial' || right == 'initial') {
|
|
112
115
|
// if (left == 'initial')
|
|
113
116
|
// left = initialValues[ucProperty];
|
|
114
117
|
// if (right == 'initial')
|
|
@@ -126,24 +129,20 @@ function propertyInterpolation(property, left, right, target) {
|
|
|
126
129
|
var interpolationArgs = merger && merger(parsedLeft, parsedRight, target);
|
|
127
130
|
|
|
128
131
|
if (interpolationArgs) {
|
|
132
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
129
133
|
var interp_1 = InterpolationFactory.apply(void 0, __spreadArray([], __read(interpolationArgs), false));
|
|
130
134
|
return function (t) {
|
|
131
135
|
if (t === 0) return left;
|
|
132
136
|
if (t === 1) return right;
|
|
133
137
|
return interp_1(t);
|
|
134
138
|
};
|
|
135
|
-
}
|
|
139
|
+
} // eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
140
|
+
|
|
136
141
|
|
|
137
142
|
return InterpolationFactory(false, true, function (bool) {
|
|
138
143
|
return bool ? right : left;
|
|
139
144
|
});
|
|
140
145
|
}
|
|
141
|
-
|
|
142
|
-
function toCamelCase(property) {
|
|
143
|
-
return property.replace(/-(.)/g, function (_, c) {
|
|
144
|
-
return c.toUpperCase();
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
146
|
/**
|
|
148
147
|
* interpolate with number, boolean, number[], boolean[]
|
|
149
148
|
*/
|
|
@@ -172,10 +171,11 @@ function interpolate(from, to, f) {
|
|
|
172
171
|
}
|
|
173
172
|
}
|
|
174
173
|
|
|
175
|
-
throw 'Mismatched interpolation arguments ' + from + ':' + to;
|
|
174
|
+
throw new Error('Mismatched interpolation arguments ' + from + ':' + to);
|
|
176
175
|
}
|
|
177
176
|
|
|
178
|
-
var InterpolationFactory = function InterpolationFactory(from, to,
|
|
177
|
+
var InterpolationFactory = function InterpolationFactory(from, to, // eslint-disable-next-line @typescript-eslint/ban-types
|
|
178
|
+
convertToString) {
|
|
179
179
|
return function (f) {
|
|
180
180
|
return convertToString(interpolate(from, to, f));
|
|
181
181
|
};
|
package/es/utils/math.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { quat, vec2, vec4 } from 'gl-matrix';
|
|
2
|
+
import { mat3, mat4, vec3 } from 'gl-matrix';
|
|
2
3
|
export declare function getAngle(angle: number | undefined): number;
|
|
3
4
|
export declare function createVec3(x: number | vec2 | vec3 | vec4, y?: number, z?: number): vec3;
|
|
4
5
|
export declare function deg2rad(deg: number): number;
|
package/es/utils/math.js
CHANGED
|
@@ -90,7 +90,6 @@ function getEulerFromQuat(out, quat) {
|
|
|
90
90
|
|
|
91
91
|
function getEulerFromMat4(out, m) {
|
|
92
92
|
var x;
|
|
93
|
-
var y;
|
|
94
93
|
var z;
|
|
95
94
|
var halfPi = Math.PI * 0.5;
|
|
96
95
|
|
|
@@ -99,7 +98,7 @@ function getEulerFromMat4(out, m) {
|
|
|
99
98
|
sy = _a[1],
|
|
100
99
|
sz = _a[2];
|
|
101
100
|
|
|
102
|
-
y = Math.asin(-m[2] / sx);
|
|
101
|
+
var y = Math.asin(-m[2] / sx);
|
|
103
102
|
|
|
104
103
|
if (y < halfPi) {
|
|
105
104
|
if (y > -halfPi) {
|
package/es/utils/path.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DisplayObject } from '../display-objects/DisplayObject';
|
|
2
|
-
import { PathCommand } from '../types';
|
|
2
|
+
import type { PathCommand } from '../types';
|
|
3
3
|
export declare function equalizeSegments(path1: PathCommand[], path2: PathCommand[], TL?: number): PathCommand[][];
|
|
4
4
|
export declare function getDrawDirection(pathArray: PathCommand[]): boolean;
|
|
5
5
|
export declare function getPathArea(pathArray: PathCommand[]): number;
|
package/es/utils/path.js
CHANGED
|
@@ -207,9 +207,7 @@ export function getRotatedCurve(a, b) {
|
|
|
207
207
|
|
|
208
208
|
function commandsToPathString(commands, localTransform, anchor, parsedStyle) {
|
|
209
209
|
var x = parsedStyle.x,
|
|
210
|
-
y = parsedStyle.y
|
|
211
|
-
width = parsedStyle.width,
|
|
212
|
-
height = parsedStyle.height;
|
|
210
|
+
y = parsedStyle.y;
|
|
213
211
|
return commands.reduce(function (prev, cur) {
|
|
214
212
|
var path = '';
|
|
215
213
|
|
|
@@ -254,7 +252,7 @@ function polygonToCommands(points) {
|
|
|
254
252
|
});
|
|
255
253
|
}
|
|
256
254
|
|
|
257
|
-
function rectToCommands(width, height, x, y
|
|
255
|
+
function rectToCommands(width, height, x, y) {
|
|
258
256
|
// FIXME: account for radius
|
|
259
257
|
return [['M', x, y], ['L', x + width, y], ['L', x + width, y + height], ['L', x, y + height], ['Z']];
|
|
260
258
|
}
|
|
@@ -317,9 +315,8 @@ export function convertToPath(object) {
|
|
|
317
315
|
width = _h.width,
|
|
318
316
|
height = _h.height,
|
|
319
317
|
x = _h.x,
|
|
320
|
-
y = _h.y
|
|
321
|
-
|
|
322
|
-
commands = rectToCommands(width, height, x, y, radius);
|
|
318
|
+
y = _h.y;
|
|
319
|
+
commands = rectToCommands(width, height, x, y);
|
|
323
320
|
break;
|
|
324
321
|
|
|
325
322
|
case SHAPE.Path:
|
package/es/utils/raf.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
2
2
|
|
|
3
3
|
function requestAnimationFrame(fn) {
|
|
4
|
-
var method = (typeof window === "undefined" ? "undefined" : _typeof(window)) === 'object' && window.requestAnimationFrame ? window.requestAnimationFrame :
|
|
4
|
+
var method = (typeof window === "undefined" ? "undefined" : _typeof(window)) === 'object' && window.requestAnimationFrame ? window.requestAnimationFrame : // eslint-disable-next-line @typescript-eslint/ban-types
|
|
5
|
+
function (f) {
|
|
5
6
|
return setTimeout(f, 16);
|
|
6
7
|
};
|
|
7
8
|
return method(fn);
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { Syringe } from 'mana-syringe';
|
|
2
|
-
import { RendererConfig } from './types';
|
|
1
|
+
import type { Syringe } from 'mana-syringe';
|
|
2
|
+
import type { RendererConfig } from './types';
|
|
3
3
|
export interface RendererPlugin {
|
|
4
|
-
init(container: Syringe.Container)
|
|
5
|
-
destroy(container: Syringe.Container)
|
|
4
|
+
init: (container: Syringe.Container) => void;
|
|
5
|
+
destroy: (container: Syringe.Container) => void;
|
|
6
6
|
}
|
|
7
7
|
export interface IRenderer {
|
|
8
|
-
getConfig()
|
|
8
|
+
getConfig: () => RendererConfig;
|
|
9
9
|
/**
|
|
10
10
|
* register plugin at runtime
|
|
11
11
|
*/
|
|
12
|
-
registerPlugin(plugin: RendererPlugin)
|
|
12
|
+
registerPlugin: (plugin: RendererPlugin) => void;
|
|
13
13
|
/**
|
|
14
14
|
* return all registered plugins
|
|
15
15
|
*/
|
|
16
|
-
getPlugins()
|
|
16
|
+
getPlugins: () => RendererPlugin[];
|
|
17
17
|
}
|
|
18
18
|
export declare class AbstractRenderer implements IRenderer {
|
|
19
19
|
private plugins;
|
package/lib/Canvas.d.ts
CHANGED
|
@@ -5,10 +5,11 @@ import { RenderingService } from './services/RenderingService';
|
|
|
5
5
|
import { RenderingContext } from './services/RenderingContext';
|
|
6
6
|
import { EventService } from './services/EventService';
|
|
7
7
|
import { Camera } from './camera';
|
|
8
|
-
import { AbstractRenderer } from './AbstractRenderer';
|
|
8
|
+
import type { AbstractRenderer } from './AbstractRenderer';
|
|
9
9
|
import type { PointLike } from './shapes';
|
|
10
|
+
import type { IChildNode } from './dom';
|
|
10
11
|
import { Document, EventTarget } from './dom';
|
|
11
|
-
import type {
|
|
12
|
+
import type { ICanvas } from './dom/interfaces';
|
|
12
13
|
import { CustomElementRegistry } from './dom/CustomElementRegistry';
|
|
13
14
|
export declare enum CanvasEvent {
|
|
14
15
|
READY = "ready",
|
|
@@ -41,6 +42,11 @@ export declare class Canvas extends EventTarget implements ICanvas {
|
|
|
41
42
|
* rAF in auto rendering
|
|
42
43
|
*/
|
|
43
44
|
private frameId?;
|
|
45
|
+
/**
|
|
46
|
+
* cache here since inversify's resolving is very slow
|
|
47
|
+
*/
|
|
48
|
+
private eventService;
|
|
49
|
+
private renderingService;
|
|
44
50
|
constructor(config: CanvasConfig);
|
|
45
51
|
private initRenderingContext;
|
|
46
52
|
private initDefaultCamera;
|
|
@@ -59,6 +65,10 @@ export declare class Canvas extends EventTarget implements ICanvas {
|
|
|
59
65
|
getEventService(): EventService;
|
|
60
66
|
getRenderingService(): RenderingService;
|
|
61
67
|
getRenderingContext(): RenderingContext;
|
|
68
|
+
getStats(): {
|
|
69
|
+
total: number;
|
|
70
|
+
rendered: number;
|
|
71
|
+
};
|
|
62
72
|
getComputedStyle(node: DisplayObject): any;
|
|
63
73
|
destroy(destroyScenegraph?: boolean): void;
|
|
64
74
|
/**
|
|
@@ -68,9 +78,9 @@ export declare class Canvas extends EventTarget implements ICanvas {
|
|
|
68
78
|
*/
|
|
69
79
|
changeSize(width: number, height: number): void;
|
|
70
80
|
resize(width: number, height: number): void;
|
|
71
|
-
appendChild<T extends
|
|
72
|
-
insertBefore<T extends
|
|
73
|
-
removeChild<T extends
|
|
81
|
+
appendChild<T extends IChildNode>(child: T, index?: number): T;
|
|
82
|
+
insertBefore<T extends IChildNode, N extends IChildNode>(newChild: T, refChild: N | null): T;
|
|
83
|
+
removeChild<T extends IChildNode>(child: T, destroy?: boolean): T;
|
|
74
84
|
removeChildren(destroy?: boolean): void;
|
|
75
85
|
render(): void;
|
|
76
86
|
private run;
|
package/lib/Canvas.js
CHANGED
|
@@ -163,17 +163,21 @@ function (_super) {
|
|
|
163
163
|
};
|
|
164
164
|
|
|
165
165
|
Canvas.prototype.getEventService = function () {
|
|
166
|
-
return this.
|
|
166
|
+
return this.eventService;
|
|
167
167
|
};
|
|
168
168
|
|
|
169
169
|
Canvas.prototype.getRenderingService = function () {
|
|
170
|
-
return this.
|
|
170
|
+
return this.renderingService;
|
|
171
171
|
};
|
|
172
172
|
|
|
173
173
|
Canvas.prototype.getRenderingContext = function () {
|
|
174
174
|
return this.container.get(_RenderingContext.RenderingContext);
|
|
175
175
|
};
|
|
176
176
|
|
|
177
|
+
Canvas.prototype.getStats = function () {
|
|
178
|
+
return this.getRenderingService().getStats();
|
|
179
|
+
};
|
|
180
|
+
|
|
177
181
|
Canvas.prototype.getComputedStyle = function (node) {
|
|
178
182
|
return node.parsedStyle;
|
|
179
183
|
};
|
|
@@ -296,9 +300,10 @@ function (_super) {
|
|
|
296
300
|
this.loadRendererContainerModule(renderer); // init context
|
|
297
301
|
|
|
298
302
|
var contextService = this.container.get(_services.ContextService);
|
|
299
|
-
|
|
303
|
+
this.renderingService = this.container.get(_RenderingService.RenderingService);
|
|
304
|
+
this.eventService = this.container.get(_EventService.EventService);
|
|
300
305
|
contextService.init();
|
|
301
|
-
renderingService.init().then(function () {
|
|
306
|
+
this.renderingService.init().then(function () {
|
|
302
307
|
_this.emit(CanvasEvent.READY, {});
|
|
303
308
|
});
|
|
304
309
|
|
|
@@ -312,7 +317,7 @@ function (_super) {
|
|
|
312
317
|
if (renderable) {
|
|
313
318
|
renderable.renderBoundsDirty = true;
|
|
314
319
|
renderable.boundsDirty = true;
|
|
315
|
-
renderable.dirty = true;
|
|
320
|
+
renderable.dirty = true;
|
|
316
321
|
}
|
|
317
322
|
}); // keep current scenegraph unchanged, just trigger mounted event
|
|
318
323
|
|
package/lib/camera/Camera.js
CHANGED
|
@@ -894,17 +894,16 @@ function (_super) {
|
|
|
894
894
|
|
|
895
895
|
|
|
896
896
|
Camera.prototype.computeMatrix = function () {
|
|
897
|
-
|
|
898
|
-
var rotY; // 使用四元数描述 3D 旋转
|
|
897
|
+
// 使用四元数描述 3D 旋转
|
|
899
898
|
// @see https://xiaoiver.github.io/coding/2018/12/28/Camera-%E8%AE%BE%E8%AE%A1-%E4%B8%80.html
|
|
900
|
-
|
|
901
899
|
var rotZ = _glMatrix.quat.setAxisAngle(_glMatrix.quat.create(), [0, 0, 1], this.roll * DEG_2_RAD);
|
|
902
900
|
|
|
903
901
|
_glMatrix.mat4.identity(this.matrix); // only consider HCS for EXPLORING and ORBITING cameras
|
|
904
902
|
|
|
905
903
|
|
|
906
|
-
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);
|
|
907
|
-
|
|
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);
|
|
908
907
|
|
|
909
908
|
var rotQ = _glMatrix.quat.multiply(_glMatrix.quat.create(), rotY, rotX);
|
|
910
909
|
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { DisplayObject } from './DisplayObject';
|
|
2
2
|
import type { DisplayObjectConfig } from '../dom/interfaces';
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* shadow root
|
|
5
|
+
* @see https://yuque.antfin-inc.com/antv/czqvg5/pgqipg
|
|
6
|
+
*/
|
|
7
|
+
export declare abstract class CustomElement<CustomElementStyleProps> extends DisplayObject<CustomElementStyleProps> {
|
|
8
|
+
constructor(config: DisplayObjectConfig<CustomElementStyleProps>);
|
|
4
9
|
/**
|
|
5
10
|
* fired after element insert into DOM tree
|
|
6
11
|
*/
|
|
@@ -10,13 +15,7 @@ export interface CustomElement<CustomElementStyleProps> {
|
|
|
10
15
|
*/
|
|
11
16
|
disconnectedCallback?(): void;
|
|
12
17
|
attributeChangedCallback?<Key extends keyof CustomElementStyleProps>(name: Key, oldValue: CustomElementStyleProps[Key], newValue: CustomElementStyleProps[Key]): void;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* shadow root
|
|
16
|
-
* @see https://yuque.antfin-inc.com/antv/czqvg5/pgqipg
|
|
17
|
-
*/
|
|
18
|
-
export declare abstract class CustomElement<CustomElementStyleProps> extends DisplayObject<CustomElementStyleProps> {
|
|
19
|
-
constructor(config: DisplayObjectConfig<CustomElementStyleProps>);
|
|
20
18
|
private handleMounted;
|
|
19
|
+
private handleUnmounted;
|
|
21
20
|
private handleAttributeChanged;
|
|
22
21
|
}
|