@antv/g 5.0.2 → 5.0.6
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/dist/index.umd.js +1 -1
- package/es/Canvas.d.ts +14 -4
- package/es/Canvas.js +18 -10
- package/es/camera/Camera.d.ts +2 -1
- package/es/camera/Camera.js +13 -5
- package/es/components/Sortable.d.ts +4 -0
- package/es/components/Sortable.js +5 -0
- package/es/display-objects/CustomElement.d.ts +10 -11
- package/es/display-objects/CustomElement.js +20 -10
- package/es/display-objects/DisplayObject.d.ts +2 -5
- package/es/display-objects/DisplayObject.js +16 -9
- package/es/display-objects/Line.d.ts +4 -0
- package/es/display-objects/Line.js +2 -0
- package/es/dom/Document.d.ts +1 -1
- package/es/dom/Element.d.ts +9 -9
- package/es/dom/Element.js +7 -4
- package/es/dom/Node.d.ts +9 -9
- package/es/dom/interfaces.d.ts +13 -9
- package/es/dom/interfaces.js +5 -0
- package/es/global-module.d.ts +4 -0
- package/es/global-module.js +58 -71
- package/es/plugins/FrustumCullingStrategy.js +3 -1
- package/es/property-handlers/localPosition.js +4 -2
- package/es/services/RenderingService.d.ts +6 -0
- package/es/services/RenderingService.js +29 -1
- package/es/types.d.ts +8 -1
- package/es/utils/interpolation.js +10 -7
- package/lib/Canvas.d.ts +14 -4
- package/lib/Canvas.js +18 -10
- package/lib/camera/Camera.d.ts +2 -1
- package/lib/camera/Camera.js +14 -5
- package/lib/components/Sortable.d.ts +4 -0
- package/lib/components/Sortable.js +5 -0
- package/lib/display-objects/CustomElement.d.ts +10 -11
- package/lib/display-objects/CustomElement.js +20 -10
- package/lib/display-objects/DisplayObject.d.ts +2 -5
- package/lib/display-objects/DisplayObject.js +13 -8
- package/lib/display-objects/Line.d.ts +4 -0
- package/lib/display-objects/Line.js +2 -0
- package/lib/dom/Document.d.ts +1 -1
- package/lib/dom/Element.d.ts +9 -9
- package/lib/dom/Element.js +7 -4
- package/lib/dom/Node.d.ts +9 -9
- package/lib/dom/interfaces.d.ts +13 -9
- package/lib/dom/interfaces.js +5 -0
- package/lib/global-module.d.ts +4 -0
- package/lib/global-module.js +58 -71
- package/lib/plugins/FrustumCullingStrategy.js +2 -0
- package/lib/property-handlers/localPosition.js +4 -2
- package/lib/services/RenderingService.d.ts +6 -0
- package/lib/services/RenderingService.js +30 -1
- package/lib/types.d.ts +8 -1
- package/lib/utils/interpolation.js +7 -9
- package/package.json +3 -3
|
@@ -2,9 +2,8 @@ import type { mat3, vec2 } from 'gl-matrix';
|
|
|
2
2
|
import { mat4, quat, vec3 } from 'gl-matrix';
|
|
3
3
|
import type { Animation } from '../dom/Animation';
|
|
4
4
|
import { Element } from '../dom/Element';
|
|
5
|
-
import type { DisplayObjectConfig,
|
|
5
|
+
import type { DisplayObjectConfig, IChildNode } from '../dom/interfaces';
|
|
6
6
|
import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
|
|
7
|
-
import type { StylePropertyParser, StylePropertyUpdater } from '../property-handlers';
|
|
8
7
|
/**
|
|
9
8
|
* prototype chains: DisplayObject -> Element -> Node -> EventTarget
|
|
10
9
|
*
|
|
@@ -32,8 +31,6 @@ export declare class DisplayObject<StyleProps extends BaseStyleProps = any, Pars
|
|
|
32
31
|
* push to active animations after calling `animate()`
|
|
33
32
|
*/
|
|
34
33
|
private activeAnimations;
|
|
35
|
-
stylePropertyUpdaterFactory: <Key extends keyof StyleProps>(stylePropertyName: Key) => StylePropertyUpdater<any>[];
|
|
36
|
-
stylePropertyParserFactory: <Key extends keyof ParsedStyleProps>(stylePropertyName: Key) => StylePropertyParser<any, any>;
|
|
37
34
|
constructor(config: DisplayObjectConfig<StyleProps>);
|
|
38
35
|
destroy(): void;
|
|
39
36
|
cloneNode(deep?: boolean): this;
|
|
@@ -193,7 +190,7 @@ export declare class DisplayObject<StyleProps extends BaseStyleProps = any, Pars
|
|
|
193
190
|
* compatible with G 3.0
|
|
194
191
|
* @deprecated
|
|
195
192
|
*/
|
|
196
|
-
add<T extends
|
|
193
|
+
add<T extends IChildNode>(child: T, index?: number): T;
|
|
197
194
|
/**
|
|
198
195
|
* @alias style.clipPath
|
|
199
196
|
* @deprecated
|
|
@@ -23,12 +23,12 @@ var _types = require("../types");
|
|
|
23
23
|
|
|
24
24
|
var _utils = require("../utils");
|
|
25
25
|
|
|
26
|
-
var _propertyHandlers = require("../property-handlers");
|
|
27
|
-
|
|
28
26
|
var _globalModule = require("../global-module");
|
|
29
27
|
|
|
30
28
|
var _services = require("../services");
|
|
31
29
|
|
|
30
|
+
// import type { StylePropertyParser, StylePropertyUpdater } from '../property-handlers';
|
|
31
|
+
// import { StylePropertyParserFactory, StylePropertyUpdaterFactory } from '../property-handlers';
|
|
32
32
|
var DEFAULT_STYLE_PROPS = {
|
|
33
33
|
anchor: [0, 0, 0],
|
|
34
34
|
origin: [0, 0, 0],
|
|
@@ -58,7 +58,12 @@ var DEFAULT_STYLE_PROPS = {
|
|
|
58
58
|
var DisplayObject =
|
|
59
59
|
/** @class */
|
|
60
60
|
function (_super) {
|
|
61
|
-
(0, _tslib.__extends)(DisplayObject, _super);
|
|
61
|
+
(0, _tslib.__extends)(DisplayObject, _super); // stylePropertyUpdaterFactory = globalContainer.get<
|
|
62
|
+
// <Key extends keyof StyleProps>(stylePropertyName: Key) => StylePropertyUpdater<any>[]
|
|
63
|
+
// >(StylePropertyUpdaterFactory);
|
|
64
|
+
// stylePropertyParserFactory = globalContainer.get<
|
|
65
|
+
// <Key extends keyof ParsedStyleProps>(stylePropertyName: Key) => StylePropertyParser<any, any>
|
|
66
|
+
// >(StylePropertyParserFactory);
|
|
62
67
|
|
|
63
68
|
function DisplayObject(config) {
|
|
64
69
|
var _a, _b, _c;
|
|
@@ -69,9 +74,7 @@ function (_super) {
|
|
|
69
74
|
*/
|
|
70
75
|
|
|
71
76
|
|
|
72
|
-
_this.activeAnimations = [];
|
|
73
|
-
_this.stylePropertyUpdaterFactory = _globalModule.globalContainer.get(_propertyHandlers.StylePropertyUpdaterFactory);
|
|
74
|
-
_this.stylePropertyParserFactory = _globalModule.globalContainer.get(_propertyHandlers.StylePropertyParserFactory); // assign name, id to config
|
|
77
|
+
_this.activeAnimations = []; // assign name, id to config
|
|
75
78
|
// eg. group.get('name')
|
|
76
79
|
|
|
77
80
|
_this.config = config; // compatible with G 3.0
|
|
@@ -199,7 +202,8 @@ function (_super) {
|
|
|
199
202
|
|
|
200
203
|
|
|
201
204
|
DisplayObject.prototype.parseStyleProperty = function (name, value) {
|
|
202
|
-
|
|
205
|
+
// const stylePropertyParser = this.stylePropertyParserFactory(name);
|
|
206
|
+
var stylePropertyParser = _globalModule.stylePropertyParserFactory[name];
|
|
203
207
|
|
|
204
208
|
if (stylePropertyParser) {
|
|
205
209
|
// @ts-ignore
|
|
@@ -212,9 +216,10 @@ function (_super) {
|
|
|
212
216
|
DisplayObject.prototype.updateStyleProperty = function (name, oldParsedValue, newParsedValue) {
|
|
213
217
|
var _this = this; // update property, which may cause AABB re-calc
|
|
214
218
|
// @ts-ignore
|
|
219
|
+
// const stylePropertyUpdaters = this.stylePropertyUpdaterFactory(name);
|
|
215
220
|
|
|
216
221
|
|
|
217
|
-
var stylePropertyUpdaters =
|
|
222
|
+
var stylePropertyUpdaters = _globalModule.stylePropertyUpdaterFactory[name];
|
|
218
223
|
|
|
219
224
|
if (stylePropertyUpdaters) {
|
|
220
225
|
stylePropertyUpdaters.forEach(function (updater) {
|
|
@@ -7,12 +7,16 @@ export interface LineStyleProps extends BaseStyleProps {
|
|
|
7
7
|
y1: number;
|
|
8
8
|
x2: number;
|
|
9
9
|
y2: number;
|
|
10
|
+
z1?: number;
|
|
11
|
+
z2?: number;
|
|
10
12
|
}
|
|
11
13
|
export interface ParsedLineStyleProps extends ParsedBaseStyleProps {
|
|
12
14
|
x1: number;
|
|
13
15
|
y1: number;
|
|
14
16
|
x2: number;
|
|
15
17
|
y2: number;
|
|
18
|
+
z1?: number;
|
|
19
|
+
z2?: number;
|
|
16
20
|
defX: number;
|
|
17
21
|
defY: number;
|
|
18
22
|
}
|
package/lib/dom/Document.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ export declare class Document extends Node implements IDocument {
|
|
|
34
34
|
* @example const circle = document.createElement('circle', { style: { r: 10 } });
|
|
35
35
|
*/
|
|
36
36
|
createElement<T extends DisplayObject<StyleProps>, StyleProps extends BaseStyleProps>(tagName: string, options: DisplayObjectConfig<StyleProps>): T;
|
|
37
|
-
cloneNode(deep?: boolean):
|
|
37
|
+
cloneNode(deep?: boolean): this;
|
|
38
38
|
destroy(): void;
|
|
39
39
|
/**
|
|
40
40
|
* eg. Uncaught DOMException: Failed to execute 'appendChild' on 'Node': Only one element on document allowed.
|
package/lib/dom/Element.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { Cullable, Geometry, Renderable, Transform, Sortable } from '../componen
|
|
|
3
3
|
import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
|
|
4
4
|
import { Node } from './Node';
|
|
5
5
|
import type { AABB, Rectangle } from '../shapes';
|
|
6
|
-
import type { IEventTarget,
|
|
6
|
+
import type { IEventTarget, IElement, INode } from './interfaces';
|
|
7
7
|
/**
|
|
8
8
|
* Has following capabilities:
|
|
9
9
|
* * Node insert/remove, eg. appendChild, removeChild, remove...
|
|
@@ -51,8 +51,8 @@ export declare class Element<StyleProps extends BaseStyleProps = any, ParsedStyl
|
|
|
51
51
|
get previousSibling(): IElement | null;
|
|
52
52
|
cloneNode(deep?: boolean): this;
|
|
53
53
|
appendChild<T extends INode>(child: T, index?: number): T;
|
|
54
|
-
insertBefore<T extends INode>(newChild: T, refChild:
|
|
55
|
-
replaceChild<T extends INode
|
|
54
|
+
insertBefore<T extends INode>(newChild: T, refChild: INode | null): T;
|
|
55
|
+
replaceChild<T extends INode>(newChild: INode, oldChild: T, destroy?: boolean): T;
|
|
56
56
|
removeChild<T extends INode>(child: T, destroy?: boolean): T;
|
|
57
57
|
removeChildren(destroy?: boolean): void;
|
|
58
58
|
/**
|
|
@@ -73,27 +73,27 @@ export declare class Element<StyleProps extends BaseStyleProps = any, ParsedStyl
|
|
|
73
73
|
/**
|
|
74
74
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/after
|
|
75
75
|
*/
|
|
76
|
-
after(...nodes:
|
|
76
|
+
after(...nodes: INode[]): void;
|
|
77
77
|
/**
|
|
78
78
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/before
|
|
79
79
|
*/
|
|
80
|
-
before(...nodes:
|
|
80
|
+
before(...nodes: INode[]): void;
|
|
81
81
|
/**
|
|
82
82
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/replaceWith
|
|
83
83
|
*/
|
|
84
|
-
replaceWith(...nodes:
|
|
84
|
+
replaceWith(...nodes: INode[]): void;
|
|
85
85
|
/**
|
|
86
86
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/append
|
|
87
87
|
*/
|
|
88
|
-
append(...nodes:
|
|
88
|
+
append(...nodes: INode[]): void;
|
|
89
89
|
/**
|
|
90
90
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/prepend
|
|
91
91
|
*/
|
|
92
|
-
prepend(...nodes:
|
|
92
|
+
prepend(...nodes: INode[]): void;
|
|
93
93
|
/**
|
|
94
94
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/replaceChildren
|
|
95
95
|
*/
|
|
96
|
-
replaceChildren(...nodes:
|
|
96
|
+
replaceChildren(...nodes: INode[]): void;
|
|
97
97
|
/**
|
|
98
98
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/remove
|
|
99
99
|
*/
|
package/lib/dom/Element.js
CHANGED
|
@@ -312,6 +312,8 @@ function (_super) {
|
|
|
312
312
|
|
|
313
313
|
|
|
314
314
|
Element.prototype.before = function () {
|
|
315
|
+
var _a;
|
|
316
|
+
|
|
315
317
|
var nodes = [];
|
|
316
318
|
|
|
317
319
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
@@ -321,12 +323,13 @@ function (_super) {
|
|
|
321
323
|
if (this.parentNode) {
|
|
322
324
|
var index = this.parentNode.childNodes.indexOf(this);
|
|
323
325
|
|
|
324
|
-
var
|
|
325
|
-
first =
|
|
326
|
-
rest =
|
|
326
|
+
var _b = (0, _tslib.__read)(nodes),
|
|
327
|
+
first = _b[0],
|
|
328
|
+
rest = _b.slice(1);
|
|
327
329
|
|
|
328
330
|
this.parentNode.appendChild(first, index);
|
|
329
|
-
|
|
331
|
+
|
|
332
|
+
(_a = first).after.apply(_a, (0, _tslib.__spreadArray)([], (0, _tslib.__read)(rest), false));
|
|
330
333
|
}
|
|
331
334
|
};
|
|
332
335
|
/**
|
package/lib/dom/Node.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export declare abstract class Node extends EventTarget implements INode {
|
|
|
28
28
|
* Returns the children.
|
|
29
29
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Node/childNodes
|
|
30
30
|
*/
|
|
31
|
-
childNodes:
|
|
31
|
+
childNodes: IChildNode[];
|
|
32
32
|
/**
|
|
33
33
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Node/nodeType
|
|
34
34
|
*/
|
|
@@ -70,14 +70,14 @@ export declare abstract class Node extends EventTarget implements INode {
|
|
|
70
70
|
*/
|
|
71
71
|
get parent(): INode | null;
|
|
72
72
|
get parentElement(): IElement | null;
|
|
73
|
-
get nextSibling():
|
|
74
|
-
get previousSibling():
|
|
75
|
-
get firstChild():
|
|
76
|
-
get lastChild():
|
|
73
|
+
get nextSibling(): IChildNode | null;
|
|
74
|
+
get previousSibling(): IChildNode | null;
|
|
75
|
+
get firstChild(): IChildNode | null;
|
|
76
|
+
get lastChild(): IChildNode | null;
|
|
77
77
|
/**
|
|
78
78
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Node/cloneNode
|
|
79
79
|
*/
|
|
80
|
-
abstract cloneNode(deep?: boolean):
|
|
80
|
+
abstract cloneNode(deep?: boolean): this;
|
|
81
81
|
/**
|
|
82
82
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Node/appendChild
|
|
83
83
|
*/
|
|
@@ -93,14 +93,14 @@ export declare abstract class Node extends EventTarget implements INode {
|
|
|
93
93
|
/**
|
|
94
94
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Node/replaceChild
|
|
95
95
|
*/
|
|
96
|
-
abstract replaceChild<T extends INode
|
|
96
|
+
abstract replaceChild<T extends INode>(newChild: INode, oldChild: T, destroy?: boolean): T;
|
|
97
97
|
abstract destroy(): void;
|
|
98
98
|
/**
|
|
99
99
|
* @deprecated
|
|
100
100
|
* @alias contains
|
|
101
101
|
*/
|
|
102
|
-
contain(other:
|
|
103
|
-
contains(other:
|
|
102
|
+
contain<T extends INode>(other: T | null): boolean;
|
|
103
|
+
contains<T extends INode>(other: T | null): boolean;
|
|
104
104
|
getAncestor(n: number): INode | null;
|
|
105
105
|
forEach(callback: (o: INode) => void | boolean): void;
|
|
106
106
|
}
|
package/lib/dom/interfaces.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type EventEmitter from 'eventemitter3';
|
|
2
2
|
import type { AnimationTimeline } from './AnimationTimeline';
|
|
3
|
-
import type { BaseStyleProps,
|
|
3
|
+
import type { BaseStyleProps, SHAPE } from '../types';
|
|
4
4
|
import type { FederatedEvent } from './FederatedEvent';
|
|
5
5
|
import type { CustomElementRegistry } from './CustomElementRegistry';
|
|
6
6
|
import type { DisplayObject } from '..';
|
|
@@ -31,7 +31,11 @@ export declare enum ElementEvent {
|
|
|
31
31
|
CHILD_REMOVED = "child-removed",
|
|
32
32
|
MOUNTED = "mounted",
|
|
33
33
|
UNMOUNTED = "unmounted",
|
|
34
|
-
BOUNDS_CHANGED = "bounds-changed"
|
|
34
|
+
BOUNDS_CHANGED = "bounds-changed",
|
|
35
|
+
/**
|
|
36
|
+
* trigger when z-index changed
|
|
37
|
+
*/
|
|
38
|
+
RENDER_ORDER_CHANGED = "render-order-changed"
|
|
35
39
|
}
|
|
36
40
|
export interface IEventTarget {
|
|
37
41
|
emitter: EventEmitter;
|
|
@@ -52,11 +56,11 @@ export interface INode extends IEventTarget {
|
|
|
52
56
|
/**
|
|
53
57
|
* Returns the children.
|
|
54
58
|
*/
|
|
55
|
-
readonly childNodes:
|
|
59
|
+
readonly childNodes: IChildNode[];
|
|
56
60
|
/**
|
|
57
61
|
* Returns the first child.
|
|
58
62
|
*/
|
|
59
|
-
readonly firstChild:
|
|
63
|
+
readonly firstChild: IChildNode | null;
|
|
60
64
|
/**
|
|
61
65
|
* Returns true if node is connected and false otherwise.
|
|
62
66
|
*/
|
|
@@ -64,11 +68,11 @@ export interface INode extends IEventTarget {
|
|
|
64
68
|
/**
|
|
65
69
|
* Returns the last child.
|
|
66
70
|
*/
|
|
67
|
-
readonly lastChild:
|
|
71
|
+
readonly lastChild: IChildNode | null;
|
|
68
72
|
/**
|
|
69
73
|
* Returns the next sibling.
|
|
70
74
|
*/
|
|
71
|
-
readonly nextSibling:
|
|
75
|
+
readonly nextSibling: IChildNode | null;
|
|
72
76
|
/**
|
|
73
77
|
* Returns a string appropriate for the type of node.
|
|
74
78
|
*/
|
|
@@ -93,7 +97,7 @@ export interface INode extends IEventTarget {
|
|
|
93
97
|
/**
|
|
94
98
|
* Returns the previous sibling.
|
|
95
99
|
*/
|
|
96
|
-
readonly previousSibling:
|
|
100
|
+
readonly previousSibling: IChildNode | null;
|
|
97
101
|
textContent: string | null;
|
|
98
102
|
appendChild: <T extends INode>(newChild: T, index?: number) => T;
|
|
99
103
|
/**
|
|
@@ -138,7 +142,7 @@ export interface INode extends IEventTarget {
|
|
|
138
142
|
*/
|
|
139
143
|
normalize: () => void;
|
|
140
144
|
removeChild: <T extends INode>(oldChild: T, destroy?: boolean) => T;
|
|
141
|
-
replaceChild: <T extends INode
|
|
145
|
+
replaceChild: <T extends INode>(newChild: INode, oldChild: T, destroy?: boolean) => T;
|
|
142
146
|
/**
|
|
143
147
|
* Destroy itself.
|
|
144
148
|
*/
|
|
@@ -250,7 +254,7 @@ export interface DisplayObjectConfig<StyleProps> {
|
|
|
250
254
|
*/
|
|
251
255
|
interactive?: boolean;
|
|
252
256
|
}
|
|
253
|
-
export interface IElement<StyleProps
|
|
257
|
+
export interface IElement<StyleProps = any, ParsedStyleProps = any> extends INode, IChildNode, IParentNode {
|
|
254
258
|
/**
|
|
255
259
|
* Returns the value of element's id content attribute. Can be set to change it.
|
|
256
260
|
*/
|
package/lib/dom/interfaces.js
CHANGED
|
@@ -37,4 +37,9 @@ exports.ElementEvent = ElementEvent;
|
|
|
37
37
|
ElementEvent["MOUNTED"] = "mounted";
|
|
38
38
|
ElementEvent["UNMOUNTED"] = "unmounted";
|
|
39
39
|
ElementEvent["BOUNDS_CHANGED"] = "bounds-changed";
|
|
40
|
+
/**
|
|
41
|
+
* trigger when z-index changed
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
ElementEvent["RENDER_ORDER_CHANGED"] = "render-order-changed";
|
|
40
45
|
})(ElementEvent || (exports.ElementEvent = ElementEvent = {}));
|
package/lib/global-module.d.ts
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
|
+
import type { StylePropertyParser, StylePropertyMerger, StylePropertyUpdater } from './property-handlers';
|
|
1
2
|
export declare const globalContainer: import("mana-syringe").Container;
|
|
3
|
+
export declare const stylePropertyParserFactory: Record<string, StylePropertyParser<any, any>>;
|
|
4
|
+
export declare const stylePropertyUpdaterFactory: Record<string, StylePropertyUpdater<any>[]>;
|
|
5
|
+
export declare const stylePropertyMergerFactory: Record<string, StylePropertyMerger<any, any>>;
|
|
2
6
|
export declare const containerModule: import("mana-syringe").SyringeModule;
|
package/lib/global-module.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.globalContainer = exports.containerModule = void 0;
|
|
6
|
+
exports.stylePropertyUpdaterFactory = exports.stylePropertyParserFactory = exports.stylePropertyMergerFactory = exports.globalContainer = exports.containerModule = void 0;
|
|
7
7
|
|
|
8
8
|
var _manaSyringe = require("mana-syringe");
|
|
9
9
|
|
|
@@ -27,6 +27,12 @@ var _propertyHandlers = require("./property-handlers");
|
|
|
27
27
|
|
|
28
28
|
var globalContainer = _manaSyringe.GlobalContainer;
|
|
29
29
|
exports.globalContainer = globalContainer;
|
|
30
|
+
var stylePropertyParserFactory = {};
|
|
31
|
+
exports.stylePropertyParserFactory = stylePropertyParserFactory;
|
|
32
|
+
var stylePropertyUpdaterFactory = {};
|
|
33
|
+
exports.stylePropertyUpdaterFactory = stylePropertyUpdaterFactory;
|
|
34
|
+
var stylePropertyMergerFactory = {};
|
|
35
|
+
exports.stylePropertyMergerFactory = stylePropertyMergerFactory;
|
|
30
36
|
var containerModule = (0, _manaSyringe.Module)(function (register) {
|
|
31
37
|
(0, _manaSyringe.decorate)((0, _manaSyringe.injectable)(), _eventemitter.EventEmitter); // bind DisplayObject pool
|
|
32
38
|
|
|
@@ -74,83 +80,65 @@ var containerModule = (0, _manaSyringe.Module)(function (register) {
|
|
|
74
80
|
return cache[tagName];
|
|
75
81
|
};
|
|
76
82
|
}
|
|
77
|
-
}); // bind style property handlers
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
return cache[propertyName];
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
});
|
|
83
|
+
}); // // bind style property handlers
|
|
84
|
+
// register({
|
|
85
|
+
// token: StylePropertyParserFactory,
|
|
86
|
+
// useFactory: (context) => {
|
|
87
|
+
// const cache = {};
|
|
88
|
+
// return (propertyName: string) => {
|
|
89
|
+
// if (!cache[propertyName]) {
|
|
90
|
+
// if (context.container.isBoundNamed(StylePropertyParser, propertyName)) {
|
|
91
|
+
// cache[propertyName] = context.container.getNamed(StylePropertyParser, propertyName);
|
|
92
|
+
// }
|
|
93
|
+
// }
|
|
94
|
+
// return cache[propertyName];
|
|
95
|
+
// };
|
|
96
|
+
// },
|
|
97
|
+
// });
|
|
98
|
+
// register({
|
|
99
|
+
// token: StylePropertyUpdaterFactory,
|
|
100
|
+
// useFactory: (context) => {
|
|
101
|
+
// const cache = {};
|
|
102
|
+
// return (propertyName: string) => {
|
|
103
|
+
// if (!cache[propertyName]) {
|
|
104
|
+
// if (context.container.isBoundNamed(StylePropertyUpdater, propertyName)) {
|
|
105
|
+
// cache[propertyName] = context.container.getAllNamed(StylePropertyUpdater, propertyName);
|
|
106
|
+
// }
|
|
107
|
+
// }
|
|
108
|
+
// return cache[propertyName];
|
|
109
|
+
// };
|
|
110
|
+
// },
|
|
111
|
+
// });
|
|
112
|
+
// register({
|
|
113
|
+
// token: StylePropertyMergerFactory,
|
|
114
|
+
// useFactory: (context) => {
|
|
115
|
+
// const cache = {};
|
|
116
|
+
// return (propertyName: string) => {
|
|
117
|
+
// if (!cache[propertyName]) {
|
|
118
|
+
// if (context.container.isBoundNamed(StylePropertyMerger, propertyName)) {
|
|
119
|
+
// cache[propertyName] = context.container.getNamed(StylePropertyMerger, propertyName);
|
|
120
|
+
// }
|
|
121
|
+
// }
|
|
122
|
+
// return cache[propertyName];
|
|
123
|
+
// };
|
|
124
|
+
// },
|
|
125
|
+
// });
|
|
124
126
|
|
|
125
127
|
function addPropertyHandler(property, parser, merger, updater) {
|
|
126
128
|
if (parser) {
|
|
127
|
-
register({
|
|
128
|
-
token: {
|
|
129
|
-
token: _propertyHandlers.StylePropertyParser,
|
|
130
|
-
named: property
|
|
131
|
-
},
|
|
132
|
-
useValue: parser
|
|
133
|
-
});
|
|
129
|
+
stylePropertyParserFactory[property] = parser; // register({ token: { token: StylePropertyParser, named: property }, useValue: parser });
|
|
134
130
|
}
|
|
135
131
|
|
|
136
132
|
if (merger) {
|
|
137
|
-
register({
|
|
138
|
-
token: {
|
|
139
|
-
token: _propertyHandlers.StylePropertyMerger,
|
|
140
|
-
named: property
|
|
141
|
-
},
|
|
142
|
-
useValue: merger
|
|
143
|
-
});
|
|
133
|
+
stylePropertyMergerFactory[property] = merger; // register({ token: { token: StylePropertyMerger, named: property }, useValue: merger });
|
|
144
134
|
}
|
|
145
135
|
|
|
146
136
|
if (updater) {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
useValue: updater
|
|
153
|
-
});
|
|
137
|
+
if (!stylePropertyUpdaterFactory[property]) {
|
|
138
|
+
stylePropertyUpdaterFactory[property] = [];
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
stylePropertyUpdaterFactory[property].push(updater); // register({ token: { token: StylePropertyUpdater, named: property }, useValue: updater });
|
|
154
142
|
}
|
|
155
143
|
}
|
|
156
144
|
|
|
@@ -184,8 +172,7 @@ var containerModule = (0, _manaSyringe.Module)(function (register) {
|
|
|
184
172
|
|
|
185
173
|
addPropertyHandler('points', _propertyHandlers.parsePoints, undefined, undefined); // update local position
|
|
186
174
|
|
|
187
|
-
addPropertiesHandler(['x', 'y', 'points', 'path', 'x1', 'x2', 'y1', 'y2'
|
|
188
|
-
undefined, undefined, _propertyHandlers.updateLocalPosition);
|
|
175
|
+
addPropertiesHandler(['x', 'y', 'z', 'points', 'path', 'x1', 'x2', 'y1', 'y2', 'z1', 'z2'], undefined, undefined, _propertyHandlers.updateLocalPosition);
|
|
189
176
|
addPropertyHandler('filter', _propertyHandlers.parseFilter, undefined, undefined);
|
|
190
177
|
addPropertyHandler('anchor', undefined, undefined, _propertyHandlers.updateAnchor);
|
|
191
178
|
});
|
|
@@ -15,6 +15,8 @@ var _CullingPlugin = require("./CullingPlugin");
|
|
|
15
15
|
|
|
16
16
|
var _shapes = require("../shapes");
|
|
17
17
|
|
|
18
|
+
// import { vec3, mat4 } from 'gl-matrix';
|
|
19
|
+
// import { inject, singleton } from 'mana-syringe';
|
|
18
20
|
// import type { Element } from '../dom';
|
|
19
21
|
var FrustumCullingStrategy =
|
|
20
22
|
/** @class */
|
|
@@ -10,7 +10,9 @@ function updateLocalPosition(oldValue, newValue, object) {
|
|
|
10
10
|
_b = _a.x,
|
|
11
11
|
x = _b === void 0 ? 0 : _b,
|
|
12
12
|
_c = _a.y,
|
|
13
|
-
y = _c === void 0 ? 0 : _c
|
|
13
|
+
y = _c === void 0 ? 0 : _c,
|
|
14
|
+
_d = _a.z,
|
|
15
|
+
z = _d === void 0 ? 0 : _d; // update local position when x/y changed
|
|
14
16
|
|
|
15
|
-
object.setLocalPosition(x, y);
|
|
17
|
+
object.setLocalPosition(x, y, z);
|
|
16
18
|
}
|
|
@@ -24,6 +24,8 @@ export declare class RenderingService {
|
|
|
24
24
|
private renderingContext;
|
|
25
25
|
private sceneGraphService;
|
|
26
26
|
private inited;
|
|
27
|
+
private stats;
|
|
28
|
+
private zIndexCounter;
|
|
27
29
|
hooks: {
|
|
28
30
|
init: AsyncSeriesHook<[], import("tapable").UnsetAdditionalOptions>;
|
|
29
31
|
prepare: SyncWaterfallHook<[DisplayObject<any, any>], import("tapable").UnsetAdditionalOptions>;
|
|
@@ -45,6 +47,10 @@ export declare class RenderingService {
|
|
|
45
47
|
pointerWheel: SyncHook<[InteractivePointerEvent], void, import("tapable").UnsetAdditionalOptions>;
|
|
46
48
|
};
|
|
47
49
|
init(): Promise<void>;
|
|
50
|
+
getStats(): {
|
|
51
|
+
total: number;
|
|
52
|
+
rendered: number;
|
|
53
|
+
};
|
|
48
54
|
render(): void;
|
|
49
55
|
private renderDisplayObject;
|
|
50
56
|
destroy(): void;
|
|
@@ -11,6 +11,8 @@ var _manaSyringe = require("mana-syringe");
|
|
|
11
11
|
|
|
12
12
|
var _tapable = require("tapable");
|
|
13
13
|
|
|
14
|
+
var _dom = require("../dom");
|
|
15
|
+
|
|
14
16
|
var _RenderingContext = require("./RenderingContext");
|
|
15
17
|
|
|
16
18
|
var _SceneGraphService = require("./SceneGraphService");
|
|
@@ -34,6 +36,11 @@ var RenderingService =
|
|
|
34
36
|
function () {
|
|
35
37
|
function RenderingService() {
|
|
36
38
|
this.inited = false;
|
|
39
|
+
this.stats = {
|
|
40
|
+
total: 0,
|
|
41
|
+
rendered: 0
|
|
42
|
+
};
|
|
43
|
+
this.zIndexCounter = 0;
|
|
37
44
|
this.hooks = {
|
|
38
45
|
init: new _tapable.AsyncSeriesHook(),
|
|
39
46
|
prepare: new _tapable.SyncWaterfallHook(['object']),
|
|
@@ -86,7 +93,14 @@ function () {
|
|
|
86
93
|
});
|
|
87
94
|
};
|
|
88
95
|
|
|
96
|
+
RenderingService.prototype.getStats = function () {
|
|
97
|
+
return this.stats;
|
|
98
|
+
};
|
|
99
|
+
|
|
89
100
|
RenderingService.prototype.render = function () {
|
|
101
|
+
this.stats.total = 0;
|
|
102
|
+
this.stats.rendered = 0;
|
|
103
|
+
this.zIndexCounter = 0;
|
|
90
104
|
this.sceneGraphService.syncHierarchy(this.renderingContext.root);
|
|
91
105
|
|
|
92
106
|
if (this.renderingContext.renderReasons.size && this.inited) {
|
|
@@ -103,7 +117,8 @@ function () {
|
|
|
103
117
|
}
|
|
104
118
|
|
|
105
119
|
this.renderingContext.renderReasons.clear();
|
|
106
|
-
}
|
|
120
|
+
} // console.log('render objects: ', this.stats.count);
|
|
121
|
+
|
|
107
122
|
};
|
|
108
123
|
|
|
109
124
|
RenderingService.prototype.renderDisplayObject = function (displayObject) {
|
|
@@ -111,8 +126,12 @@ function () {
|
|
|
111
126
|
|
|
112
127
|
|
|
113
128
|
var objectToRender = this.hooks.prepare.call(displayObject);
|
|
129
|
+
displayObject.sortable.renderOrder = this.zIndexCounter++;
|
|
130
|
+
this.stats.total++;
|
|
114
131
|
|
|
115
132
|
if (objectToRender) {
|
|
133
|
+
this.stats.rendered++;
|
|
134
|
+
|
|
116
135
|
if (!this.renderingContext.dirty) {
|
|
117
136
|
this.renderingContext.dirty = true;
|
|
118
137
|
this.hooks.beginFrame.call();
|
|
@@ -126,10 +145,12 @@ function () {
|
|
|
126
145
|
|
|
127
146
|
|
|
128
147
|
var sortable = displayObject.sortable;
|
|
148
|
+
var renderOrderChanged = false;
|
|
129
149
|
|
|
130
150
|
if (sortable.dirty) {
|
|
131
151
|
// sortable.sorted = [...(displayObject.childNodes as IElement[])].sort(sortByZIndex);
|
|
132
152
|
sortable.sorted = displayObject.childNodes.slice().sort(_SceneGraphService.sortByZIndex);
|
|
153
|
+
renderOrderChanged = true;
|
|
133
154
|
sortable.dirty = false;
|
|
134
155
|
} // recursive rendering its children
|
|
135
156
|
|
|
@@ -137,6 +158,14 @@ function () {
|
|
|
137
158
|
(sortable.sorted || displayObject.childNodes).forEach(function (child) {
|
|
138
159
|
_this.renderDisplayObject(child);
|
|
139
160
|
});
|
|
161
|
+
|
|
162
|
+
if (renderOrderChanged) {
|
|
163
|
+
displayObject.forEach(function (child) {
|
|
164
|
+
child.emit(_dom.ElementEvent.RENDER_ORDER_CHANGED, {
|
|
165
|
+
renderOrder: child.sortable.renderOrder
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
}
|
|
140
169
|
};
|
|
141
170
|
|
|
142
171
|
RenderingService.prototype.destroy = function () {
|