@antv/g 5.0.1 → 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.
- package/LICENSE +21 -0
- package/dist/index.umd.js +2 -2
- package/es/AbstractRenderer.d.ts +7 -7
- package/es/Canvas.d.ts +1 -1
- package/es/Canvas.js +1 -1
- 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 +3 -3
- package/es/display-objects/CustomElement.js +4 -1
- package/es/display-objects/DisplayObject.d.ts +4 -3
- package/es/display-objects/DisplayObject.js +4 -3
- 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 +2 -2
- package/es/dom/Document.js +13 -6
- package/es/dom/Element.d.ts +3 -4
- package/es/dom/Element.js +5 -4
- 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 +1 -1
- package/es/dom/Node.js +11 -5
- package/es/dom/interfaces.d.ts +57 -57
- 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 +29 -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 +18 -18
- package/es/services/RenderingService.js +3 -3
- 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 -1
- 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 +6 -9
- 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 +1 -1
- package/lib/Canvas.js +1 -1
- 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 +3 -3
- package/lib/display-objects/CustomElement.js +4 -1
- package/lib/display-objects/DisplayObject.d.ts +4 -3
- package/lib/display-objects/DisplayObject.js +6 -3
- 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 +2 -2
- package/lib/dom/Document.js +13 -6
- package/lib/dom/Element.d.ts +3 -4
- package/lib/dom/Element.js +5 -4
- 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 +1 -1
- package/lib/dom/Node.js +11 -5
- package/lib/dom/interfaces.d.ts +57 -57
- 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 +26 -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 +18 -18
- package/lib/services/RenderingService.js +3 -3
- 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 -1
- 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 +6 -9
- 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
|
@@ -149,10 +149,6 @@ function parseTransform(string) {
|
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
return [];
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
function numberToLongString(x) {
|
|
155
|
-
return x.toFixed(6).replace('.000000', '');
|
|
156
152
|
} // function mergeMatrices(left: number[][], right: number[][]): [
|
|
157
153
|
// number[][], number[][], () => string,
|
|
158
154
|
// ] {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Syringe } from 'mana-syringe';
|
|
2
2
|
export declare const ContextService: Syringe.DefinedToken;
|
|
3
3
|
export interface ContextService<Context> {
|
|
4
|
-
init()
|
|
5
|
-
destroy()
|
|
6
|
-
getContext()
|
|
7
|
-
getDomElement()
|
|
8
|
-
getDPR()
|
|
9
|
-
getBoundingClientRect()
|
|
10
|
-
resize(width: number, height: number)
|
|
11
|
-
applyCursorStyle(cursor: string)
|
|
4
|
+
init: () => void;
|
|
5
|
+
destroy: () => void;
|
|
6
|
+
getContext: () => Context | null;
|
|
7
|
+
getDomElement: () => HTMLElement | null;
|
|
8
|
+
getDPR: () => number;
|
|
9
|
+
getBoundingClientRect: () => DOMRect | undefined;
|
|
10
|
+
resize: (width: number, height: number) => void;
|
|
11
|
+
applyCursorStyle: (cursor: string) => void;
|
|
12
12
|
}
|
|
@@ -2,8 +2,8 @@ import { EventEmitter } from 'eventemitter3';
|
|
|
2
2
|
import type { Cursor, EventPosition } from '../types';
|
|
3
3
|
import { CanvasConfig } from '../types';
|
|
4
4
|
import type { FederatedEvent } from '../dom/FederatedEvent';
|
|
5
|
-
import { IEventTarget } from '../dom/interfaces';
|
|
6
|
-
import { PointLike } from '../shapes';
|
|
5
|
+
import type { IEventTarget } from '../dom/interfaces';
|
|
6
|
+
import type { PointLike } from '../shapes';
|
|
7
7
|
declare type Picker = (position: EventPosition) => Promise<IEventTarget | null>;
|
|
8
8
|
export declare type EmitterListeners = Record<string, {
|
|
9
9
|
fn: (...args: any[]) => any;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Syringe } from 'mana-syringe';
|
|
2
2
|
import { SyncHook, SyncWaterfallHook, AsyncSeriesHook, AsyncSeriesWaterfallHook } from 'tapable';
|
|
3
|
-
import { DisplayObject } from '..';
|
|
4
|
-
import { EventPosition, InteractivePointerEvent } from '../types';
|
|
3
|
+
import type { DisplayObject } from '..';
|
|
4
|
+
import type { EventPosition, InteractivePointerEvent } from '../types';
|
|
5
5
|
export interface RenderingPlugin {
|
|
6
|
-
apply(renderer: RenderingService)
|
|
6
|
+
apply: (renderer: RenderingService) => void;
|
|
7
7
|
}
|
|
8
8
|
export declare const RenderingPluginContribution: Syringe.DefinedToken;
|
|
9
9
|
export interface PickingResult {
|
|
@@ -25,24 +25,24 @@ export declare class RenderingService {
|
|
|
25
25
|
private sceneGraphService;
|
|
26
26
|
private inited;
|
|
27
27
|
hooks: {
|
|
28
|
-
init: AsyncSeriesHook<
|
|
29
|
-
prepare: SyncWaterfallHook<DisplayObject<any, any
|
|
28
|
+
init: AsyncSeriesHook<[], import("tapable").UnsetAdditionalOptions>;
|
|
29
|
+
prepare: SyncWaterfallHook<[DisplayObject<any, any>], import("tapable").UnsetAdditionalOptions>;
|
|
30
30
|
/**
|
|
31
31
|
* called at beginning of each frame, won't get called if nothing to re-render
|
|
32
32
|
*/
|
|
33
|
-
beginFrame: SyncHook<
|
|
34
|
-
beforeRender: SyncHook<DisplayObject<any, any
|
|
35
|
-
render: SyncHook<DisplayObject<any, any
|
|
36
|
-
afterRender: SyncHook<DisplayObject<any, any
|
|
37
|
-
endFrame: SyncHook<
|
|
38
|
-
destroy: SyncHook<
|
|
39
|
-
pick: AsyncSeriesWaterfallHook<PickingResult, PickingResult
|
|
40
|
-
pointerDown: SyncHook<InteractivePointerEvent,
|
|
41
|
-
pointerUp: SyncHook<InteractivePointerEvent,
|
|
42
|
-
pointerMove: SyncHook<InteractivePointerEvent,
|
|
43
|
-
pointerOut: SyncHook<InteractivePointerEvent,
|
|
44
|
-
pointerOver: SyncHook<InteractivePointerEvent,
|
|
45
|
-
pointerWheel: SyncHook<InteractivePointerEvent,
|
|
33
|
+
beginFrame: SyncHook<[], void, import("tapable").UnsetAdditionalOptions>;
|
|
34
|
+
beforeRender: SyncHook<[DisplayObject<any, any>], void, import("tapable").UnsetAdditionalOptions>;
|
|
35
|
+
render: SyncHook<[DisplayObject<any, any>], void, import("tapable").UnsetAdditionalOptions>;
|
|
36
|
+
afterRender: SyncHook<[DisplayObject<any, any>], void, import("tapable").UnsetAdditionalOptions>;
|
|
37
|
+
endFrame: SyncHook<[], void, import("tapable").UnsetAdditionalOptions>;
|
|
38
|
+
destroy: SyncHook<[], void, import("tapable").UnsetAdditionalOptions>;
|
|
39
|
+
pick: AsyncSeriesWaterfallHook<[PickingResult], PickingResult>;
|
|
40
|
+
pointerDown: SyncHook<[InteractivePointerEvent], void, import("tapable").UnsetAdditionalOptions>;
|
|
41
|
+
pointerUp: SyncHook<[InteractivePointerEvent], void, import("tapable").UnsetAdditionalOptions>;
|
|
42
|
+
pointerMove: SyncHook<[InteractivePointerEvent], void, import("tapable").UnsetAdditionalOptions>;
|
|
43
|
+
pointerOut: SyncHook<[InteractivePointerEvent], void, import("tapable").UnsetAdditionalOptions>;
|
|
44
|
+
pointerOver: SyncHook<[InteractivePointerEvent], void, import("tapable").UnsetAdditionalOptions>;
|
|
45
|
+
pointerWheel: SyncHook<[InteractivePointerEvent], void, import("tapable").UnsetAdditionalOptions>;
|
|
46
46
|
};
|
|
47
47
|
init(): Promise<void>;
|
|
48
48
|
render(): void;
|
|
@@ -41,12 +41,12 @@ function () {
|
|
|
41
41
|
/**
|
|
42
42
|
* called at beginning of each frame, won't get called if nothing to re-render
|
|
43
43
|
*/
|
|
44
|
-
beginFrame: new _tapable.SyncHook(),
|
|
44
|
+
beginFrame: new _tapable.SyncHook([]),
|
|
45
45
|
beforeRender: new _tapable.SyncHook(['objectToRender']),
|
|
46
46
|
render: new _tapable.SyncHook(['objectToRender']),
|
|
47
47
|
afterRender: new _tapable.SyncHook(['objectToRender']),
|
|
48
|
-
endFrame: new _tapable.SyncHook(),
|
|
49
|
-
destroy: new _tapable.SyncHook(),
|
|
48
|
+
endFrame: new _tapable.SyncHook([]),
|
|
49
|
+
destroy: new _tapable.SyncHook([]),
|
|
50
50
|
pick: new _tapable.AsyncSeriesWaterfallHook(['result']),
|
|
51
51
|
pointerDown: new _tapable.SyncHook(['event']),
|
|
52
52
|
pointerUp: new _tapable.SyncHook(['event']),
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { IElement } from '../dom/interfaces';
|
|
1
|
+
import type { IElement } from '../dom/interfaces';
|
|
2
2
|
export declare const SceneGraphSelectorFactory = "SceneGraphSelectorFactory";
|
|
3
3
|
export declare const SceneGraphSelector = "SceneGraphSelector";
|
|
4
4
|
export interface SceneGraphSelector {
|
|
5
|
-
selectOne<R extends IElement, T extends IElement>(query: string, root: R)
|
|
6
|
-
selectAll<R extends IElement, T extends IElement>(query: string, root: R)
|
|
7
|
-
is<T extends IElement>(query: string, element: T)
|
|
5
|
+
selectOne: <R extends IElement, T extends IElement>(query: string, root: R) => T | null;
|
|
6
|
+
selectAll: <R extends IElement, T extends IElement>(query: string, root: R) => T[];
|
|
7
|
+
is: <T extends IElement>(query: string, element: T) => boolean;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* support following DOM API
|
|
@@ -16,5 +16,5 @@ export interface SceneGraphSelector {
|
|
|
16
16
|
export declare class DefaultSceneGraphSelector implements SceneGraphSelector {
|
|
17
17
|
selectOne<R extends IElement, T extends IElement>(query: string, root: R): T | null;
|
|
18
18
|
selectAll<R extends IElement, T extends IElement>(query: string, root: R): T[];
|
|
19
|
-
is<T extends IElement>(
|
|
19
|
+
is<T extends IElement>(): boolean;
|
|
20
20
|
}
|
|
@@ -62,9 +62,10 @@ function () {
|
|
|
62
62
|
return node.nodeName === query;
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
|
-
};
|
|
65
|
+
}; // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
66
|
+
|
|
66
67
|
|
|
67
|
-
DefaultSceneGraphSelector.prototype.is = function (
|
|
68
|
+
DefaultSceneGraphSelector.prototype.is = function () {
|
|
68
69
|
// TODO: need a simple `matches` implementation
|
|
69
70
|
return true;
|
|
70
71
|
};
|
|
@@ -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
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.SceneGraphService = exports.DefaultSceneGraphService = void 0;
|
|
7
|
+
exports.dirtifyToRoot = dirtifyToRoot;
|
|
7
8
|
exports.sortByZIndex = sortByZIndex;
|
|
8
9
|
|
|
9
10
|
var _tslib = require("tslib");
|
|
@@ -37,6 +38,30 @@ function sortByZIndex(o1, o2) {
|
|
|
37
38
|
return zIndex1 - zIndex2;
|
|
38
39
|
}
|
|
39
40
|
|
|
41
|
+
function dirtifyToRoot(element, affectChildren) {
|
|
42
|
+
if (affectChildren === void 0) {
|
|
43
|
+
affectChildren = false;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
var p = element;
|
|
47
|
+
|
|
48
|
+
while (p) {
|
|
49
|
+
var renderable = p.renderable;
|
|
50
|
+
|
|
51
|
+
if (renderable) {
|
|
52
|
+
renderable.renderBoundsDirty = true;
|
|
53
|
+
renderable.boundsDirty = true;
|
|
54
|
+
renderable.dirty = true;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
p = p.parentNode;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
element.emit(_interfaces.ElementEvent.BOUNDS_CHANGED, {
|
|
61
|
+
affectChildren: affectChildren
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
40
65
|
var SceneGraphService = 'SceneGraphService';
|
|
41
66
|
/**
|
|
42
67
|
* update transform in scene graph
|
|
@@ -543,9 +568,7 @@ function () {
|
|
|
543
568
|
}
|
|
544
569
|
|
|
545
570
|
this.dirtifyWorldInternal(element, transform);
|
|
546
|
-
element
|
|
547
|
-
affectChildren: true
|
|
548
|
-
});
|
|
571
|
+
dirtifyToRoot(element, true);
|
|
549
572
|
};
|
|
550
573
|
|
|
551
574
|
DefaultSceneGraphService.prototype.getPosition = function (element) {
|
|
@@ -780,7 +803,15 @@ function () {
|
|
|
780
803
|
if (!childTransform.dirtyFlag) {
|
|
781
804
|
_this.dirtifyWorldInternal(child, childTransform);
|
|
782
805
|
}
|
|
783
|
-
});
|
|
806
|
+
});
|
|
807
|
+
var renderable = element.renderable;
|
|
808
|
+
|
|
809
|
+
if (renderable) {
|
|
810
|
+
renderable.renderBoundsDirty = true;
|
|
811
|
+
renderable.boundsDirty = true;
|
|
812
|
+
renderable.dirty = true;
|
|
813
|
+
} // model matrix changed
|
|
814
|
+
|
|
784
815
|
|
|
785
816
|
element.emit(_interfaces.ElementEvent.ATTRIBUTE_CHANGED, {
|
|
786
817
|
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;
|
|
@@ -18,7 +18,7 @@ var PathUpdater =
|
|
|
18
18
|
function () {
|
|
19
19
|
function PathUpdater() {}
|
|
20
20
|
|
|
21
|
-
PathUpdater.prototype.update = function (parsedStyle
|
|
21
|
+
PathUpdater.prototype.update = function (parsedStyle) {
|
|
22
22
|
var path = parsedStyle.path;
|
|
23
23
|
var _a = path.rect,
|
|
24
24
|
minX = _a.x,
|
|
@@ -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/lib/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/lib/shapes/Frustum.d.ts
CHANGED
package/lib/shapes/Polygon.d.ts
CHANGED
package/lib/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/lib/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';
|
|
@@ -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;
|
|
@@ -186,7 +186,8 @@ var getEasingDuration = function getEasingDuration(easing) {
|
|
|
186
186
|
easing = 'spring';
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
-
if (EasingDurationCache.has(easing)) return EasingDurationCache.get(easing);
|
|
189
|
+
if (EasingDurationCache.has(easing)) return EasingDurationCache.get(easing); // eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
190
|
+
|
|
190
191
|
var easingFunction = typeof easing == 'function' ? easing : getEasingFunction(easing);
|
|
191
192
|
var params = typeof easing == 'function' ? [] : parseEasingParameters(easing);
|
|
192
193
|
var frame = 1 / 6;
|
package/lib/utils/event.d.ts
CHANGED
|
@@ -141,24 +141,20 @@ function propertyInterpolation(property, left, right, target) {
|
|
|
141
141
|
var interpolationArgs = merger && merger(parsedLeft, parsedRight, target);
|
|
142
142
|
|
|
143
143
|
if (interpolationArgs) {
|
|
144
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
144
145
|
var interp_1 = InterpolationFactory.apply(void 0, (0, _tslib.__spreadArray)([], (0, _tslib.__read)(interpolationArgs), false));
|
|
145
146
|
return function (t) {
|
|
146
147
|
if (t === 0) return left;
|
|
147
148
|
if (t === 1) return right;
|
|
148
149
|
return interp_1(t);
|
|
149
150
|
};
|
|
150
|
-
}
|
|
151
|
+
} // eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
152
|
+
|
|
151
153
|
|
|
152
154
|
return InterpolationFactory(false, true, function (bool) {
|
|
153
155
|
return bool ? right : left;
|
|
154
156
|
});
|
|
155
157
|
}
|
|
156
|
-
|
|
157
|
-
function toCamelCase(property) {
|
|
158
|
-
return property.replace(/-(.)/g, function (_, c) {
|
|
159
|
-
return c.toUpperCase();
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
158
|
/**
|
|
163
159
|
* interpolate with number, boolean, number[], boolean[]
|
|
164
160
|
*/
|
|
@@ -187,10 +183,11 @@ function interpolate(from, to, f) {
|
|
|
187
183
|
}
|
|
188
184
|
}
|
|
189
185
|
|
|
190
|
-
throw 'Mismatched interpolation arguments ' + from + ':' + to;
|
|
186
|
+
throw new Error('Mismatched interpolation arguments ' + from + ':' + to);
|
|
191
187
|
}
|
|
192
188
|
|
|
193
|
-
var InterpolationFactory = function InterpolationFactory(from, to,
|
|
189
|
+
var InterpolationFactory = function InterpolationFactory(from, to, // eslint-disable-next-line @typescript-eslint/ban-types
|
|
190
|
+
convertToString) {
|
|
194
191
|
return function (f) {
|
|
195
192
|
return convertToString(interpolate(from, to, f));
|
|
196
193
|
};
|
package/lib/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/lib/utils/math.js
CHANGED
|
@@ -115,7 +115,6 @@ function getEulerFromQuat(out, quat) {
|
|
|
115
115
|
|
|
116
116
|
function getEulerFromMat4(out, m) {
|
|
117
117
|
var x;
|
|
118
|
-
var y;
|
|
119
118
|
var z;
|
|
120
119
|
var halfPi = Math.PI * 0.5;
|
|
121
120
|
|
|
@@ -124,7 +123,7 @@ function getEulerFromMat4(out, m) {
|
|
|
124
123
|
sy = _a[1],
|
|
125
124
|
sz = _a[2];
|
|
126
125
|
|
|
127
|
-
y = Math.asin(-m[2] / sx);
|
|
126
|
+
var y = Math.asin(-m[2] / sx);
|
|
128
127
|
|
|
129
128
|
if (y < halfPi) {
|
|
130
129
|
if (y > -halfPi) {
|
package/lib/utils/path.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
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;
|
|
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] | ["
|
|
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/lib/utils/path.js
CHANGED
|
@@ -225,9 +225,7 @@ function getRotatedCurve(a, b) {
|
|
|
225
225
|
|
|
226
226
|
function commandsToPathString(commands, localTransform, anchor, parsedStyle) {
|
|
227
227
|
var x = parsedStyle.x,
|
|
228
|
-
y = parsedStyle.y
|
|
229
|
-
width = parsedStyle.width,
|
|
230
|
-
height = parsedStyle.height;
|
|
228
|
+
y = parsedStyle.y;
|
|
231
229
|
return commands.reduce(function (prev, cur) {
|
|
232
230
|
var path = '';
|
|
233
231
|
|
|
@@ -280,7 +278,7 @@ function polygonToCommands(points) {
|
|
|
280
278
|
});
|
|
281
279
|
}
|
|
282
280
|
|
|
283
|
-
function rectToCommands(width, height, x, y
|
|
281
|
+
function rectToCommands(width, height, x, y) {
|
|
284
282
|
// FIXME: account for radius
|
|
285
283
|
return [['M', x, y], ['L', x + width, y], ['L', x + width, y + height], ['L', x, y + height], ['Z']];
|
|
286
284
|
}
|
|
@@ -343,9 +341,8 @@ function convertToPath(object) {
|
|
|
343
341
|
width = _h.width,
|
|
344
342
|
height = _h.height,
|
|
345
343
|
x = _h.x,
|
|
346
|
-
y = _h.y
|
|
347
|
-
|
|
348
|
-
commands = rectToCommands(width, height, x, y, radius);
|
|
344
|
+
y = _h.y;
|
|
345
|
+
commands = rectToCommands(width, height, x, y);
|
|
349
346
|
break;
|
|
350
347
|
|
|
351
348
|
case _types.SHAPE.Path:
|
package/lib/utils/raf.js
CHANGED
|
@@ -9,7 +9,8 @@ exports.requestAnimationFrame = requestAnimationFrame;
|
|
|
9
9
|
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); }
|
|
10
10
|
|
|
11
11
|
function requestAnimationFrame(fn) {
|
|
12
|
-
var method = (typeof window === "undefined" ? "undefined" : _typeof(window)) === 'object' && window.requestAnimationFrame ? window.requestAnimationFrame :
|
|
12
|
+
var method = (typeof window === "undefined" ? "undefined" : _typeof(window)) === 'object' && window.requestAnimationFrame ? window.requestAnimationFrame : // eslint-disable-next-line @typescript-eslint/ban-types
|
|
13
|
+
function (f) {
|
|
13
14
|
return setTimeout(f, 16);
|
|
14
15
|
};
|
|
15
16
|
return method(fn);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/g",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.2",
|
|
4
4
|
"description": "A core module including ECS and DI container.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -33,22 +33,22 @@
|
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/gl-matrix": "^2.4.5",
|
|
36
|
-
"@types/offscreencanvas": "^2019.6.1"
|
|
37
|
-
"npm-run-all": "^4.1.5"
|
|
36
|
+
"@types/offscreencanvas": "^2019.6.1"
|
|
38
37
|
},
|
|
39
38
|
"homepage": "https://github.com/antvis/g#readme",
|
|
40
39
|
"dependencies": {
|
|
41
|
-
"@antv/g-math": "^1.0.
|
|
40
|
+
"@antv/g-math": "^1.0.2",
|
|
42
41
|
"@antv/path-util": "^2.0.14",
|
|
43
42
|
"@antv/util": "^2.0.13",
|
|
44
43
|
"d3-color": "^1.4.0",
|
|
45
44
|
"eventemitter3": "^4.0.0",
|
|
46
45
|
"gl-matrix": "^3.1.0",
|
|
47
46
|
"mana-syringe": "^0.2.2",
|
|
48
|
-
"tapable": "
|
|
47
|
+
"tapable": "^2.2.1",
|
|
48
|
+
"tslib": "^2.3.1"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
51
|
"umd": "webpack"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "3d4d25c30b0134186e9e6e4adb54052ee581df48"
|
|
54
54
|
}
|