@antv/g 1.0.0-alpha.32 → 1.0.0-alpha.33
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 +3 -3
- package/es/components/Transform.d.ts +2 -0
- package/es/components/Transform.js +2 -0
- package/es/display-objects/CustomElement.d.ts +0 -3
- package/es/display-objects/CustomElement.js +22 -28
- package/es/global-module.js +24 -12
- package/es/services/EventService.js +4 -5
- package/es/services/RenderingService.d.ts +1 -0
- package/es/services/RenderingService.js +5 -1
- package/es/services/SceneGraphService.d.ts +5 -1
- package/es/services/SceneGraphService.js +64 -9
- package/lib/components/Transform.d.ts +2 -0
- package/lib/components/Transform.js +2 -0
- package/lib/display-objects/CustomElement.d.ts +0 -3
- package/lib/display-objects/CustomElement.js +22 -29
- package/lib/global-module.js +24 -12
- package/lib/services/EventService.js +4 -5
- package/lib/services/RenderingService.d.ts +1 -0
- package/lib/services/RenderingService.js +3 -0
- package/lib/services/SceneGraphService.d.ts +5 -1
- package/lib/services/SceneGraphService.js +65 -9
- package/package.json +2 -2
|
@@ -16,10 +16,7 @@ export interface CustomElement<CustomElementStyleProps> {
|
|
|
16
16
|
* @see https://yuque.antfin-inc.com/antv/czqvg5/pgqipg
|
|
17
17
|
*/
|
|
18
18
|
export declare abstract class CustomElement<CustomElementStyleProps> extends DisplayObject<CustomElementStyleProps> {
|
|
19
|
-
private shadowNodes;
|
|
20
19
|
constructor(config: DisplayObjectConfig<CustomElementStyleProps>);
|
|
21
20
|
private handleMounted;
|
|
22
|
-
private handleChildInserted;
|
|
23
|
-
private handleChildRemoved;
|
|
24
21
|
private handleAttributeChanged;
|
|
25
22
|
}
|
|
@@ -9,39 +9,35 @@ import { ElementEvent } from '../dom/interfaces';
|
|
|
9
9
|
var CustomElement =
|
|
10
10
|
/** @class */
|
|
11
11
|
function (_super) {
|
|
12
|
-
__extends(CustomElement, _super);
|
|
12
|
+
__extends(CustomElement, _super); // private shadowNodes: DisplayObject[] = [];
|
|
13
|
+
|
|
13
14
|
|
|
14
15
|
function CustomElement(config) {
|
|
15
16
|
var _this = _super.call(this, config) || this;
|
|
16
17
|
|
|
17
|
-
_this.shadowNodes = [];
|
|
18
|
-
|
|
19
18
|
_this.handleMounted = function () {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
});
|
|
25
|
-
|
|
19
|
+
// this.shadowNodes.forEach((node) => {
|
|
20
|
+
// // every child and its children should turn into a shadow node
|
|
21
|
+
// // a shadow node doesn't mean to be unrenderable, it's just unsearchable in scenegraph
|
|
22
|
+
// node.shadow = true;
|
|
23
|
+
// });
|
|
26
24
|
if (_this.connectedCallback) {
|
|
27
25
|
_this.connectedCallback();
|
|
28
26
|
}
|
|
29
|
-
};
|
|
27
|
+
}; // private handleChildInserted = (e: FederatedEvent) => {
|
|
28
|
+
// (e.target as DisplayObject).forEach((node) => {
|
|
29
|
+
// // append children like other shapes after mounted
|
|
30
|
+
// if (!this.isConnected) {
|
|
31
|
+
// this.shadowNodes.push(node as DisplayObject);
|
|
32
|
+
// }
|
|
33
|
+
// });
|
|
34
|
+
// };
|
|
35
|
+
// private handleChildRemoved = (e: FederatedEvent) => {
|
|
36
|
+
// (e.target as DisplayObject).forEach((node) => {
|
|
37
|
+
// node.shadow = false;
|
|
38
|
+
// });
|
|
39
|
+
// };
|
|
30
40
|
|
|
31
|
-
_this.handleChildInserted = function (e) {
|
|
32
|
-
e.target.forEach(function (node) {
|
|
33
|
-
// append children like other shapes after mounted
|
|
34
|
-
if (!_this.isConnected) {
|
|
35
|
-
_this.shadowNodes.push(node);
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
_this.handleChildRemoved = function (e) {
|
|
41
|
-
e.target.forEach(function (node) {
|
|
42
|
-
node.shadow = false;
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
41
|
|
|
46
42
|
_this.handleAttributeChanged = function (e) {
|
|
47
43
|
// only listen itself
|
|
@@ -55,11 +51,9 @@ function (_super) {
|
|
|
55
51
|
oldValue = _a.oldValue,
|
|
56
52
|
newValue = _a.newValue;
|
|
57
53
|
_this.attributeChangedCallback && _this.attributeChangedCallback(attributeName, oldValue, newValue);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
_this.addEventListener(ElementEvent.CHILD_INSERTED, _this.handleChildInserted);
|
|
54
|
+
}; // this.addEventListener(ElementEvent.CHILD_INSERTED, this.handleChildInserted);
|
|
55
|
+
// this.addEventListener(ElementEvent.CHILD_REMOVED, this.handleChildRemoved);
|
|
61
56
|
|
|
62
|
-
_this.addEventListener(ElementEvent.CHILD_REMOVED, _this.handleChildRemoved);
|
|
63
57
|
|
|
64
58
|
if (_this.attributeChangedCallback) {
|
|
65
59
|
_this.addEventListener(ElementEvent.ATTRIBUTE_CHANGED, _this.handleAttributeChanged);
|
package/es/global-module.js
CHANGED
|
@@ -43,12 +43,15 @@ export var containerModule = Module(function (register) {
|
|
|
43
43
|
register({
|
|
44
44
|
token: GeometryUpdaterFactory,
|
|
45
45
|
useFactory: function useFactory(context) {
|
|
46
|
+
var cache = {};
|
|
46
47
|
return function (tagName) {
|
|
47
|
-
if (
|
|
48
|
-
|
|
48
|
+
if (!cache[tagName]) {
|
|
49
|
+
if (context.container.isBoundNamed(GeometryAABBUpdater, tagName)) {
|
|
50
|
+
cache[tagName] = context.container.getNamed(GeometryAABBUpdater, tagName);
|
|
51
|
+
}
|
|
49
52
|
}
|
|
50
53
|
|
|
51
|
-
return
|
|
54
|
+
return cache[tagName];
|
|
52
55
|
};
|
|
53
56
|
}
|
|
54
57
|
}); // bind style property handlers
|
|
@@ -56,36 +59,45 @@ export var containerModule = Module(function (register) {
|
|
|
56
59
|
register({
|
|
57
60
|
token: StylePropertyParserFactory,
|
|
58
61
|
useFactory: function useFactory(context) {
|
|
62
|
+
var cache = {};
|
|
59
63
|
return function (propertyName) {
|
|
60
|
-
if (
|
|
61
|
-
|
|
64
|
+
if (!cache[propertyName]) {
|
|
65
|
+
if (context.container.isBoundNamed(StylePropertyParser, propertyName)) {
|
|
66
|
+
cache[propertyName] = context.container.getNamed(StylePropertyParser, propertyName);
|
|
67
|
+
}
|
|
62
68
|
}
|
|
63
69
|
|
|
64
|
-
return
|
|
70
|
+
return cache[propertyName];
|
|
65
71
|
};
|
|
66
72
|
}
|
|
67
73
|
});
|
|
68
74
|
register({
|
|
69
75
|
token: StylePropertyUpdaterFactory,
|
|
70
76
|
useFactory: function useFactory(context) {
|
|
77
|
+
var cache = {};
|
|
71
78
|
return function (propertyName) {
|
|
72
|
-
if (
|
|
73
|
-
|
|
79
|
+
if (!cache[propertyName]) {
|
|
80
|
+
if (context.container.isBoundNamed(StylePropertyUpdater, propertyName)) {
|
|
81
|
+
cache[propertyName] = context.container.getAllNamed(StylePropertyUpdater, propertyName);
|
|
82
|
+
}
|
|
74
83
|
}
|
|
75
84
|
|
|
76
|
-
return
|
|
85
|
+
return cache[propertyName];
|
|
77
86
|
};
|
|
78
87
|
}
|
|
79
88
|
});
|
|
80
89
|
register({
|
|
81
90
|
token: StylePropertyMergerFactory,
|
|
82
91
|
useFactory: function useFactory(context) {
|
|
92
|
+
var cache = {};
|
|
83
93
|
return function (propertyName) {
|
|
84
|
-
if (
|
|
85
|
-
|
|
94
|
+
if (!cache[propertyName]) {
|
|
95
|
+
if (context.container.isBoundNamed(StylePropertyMerger, propertyName)) {
|
|
96
|
+
cache[propertyName] = context.container.getNamed(StylePropertyMerger, propertyName);
|
|
97
|
+
}
|
|
86
98
|
}
|
|
87
99
|
|
|
88
|
-
return
|
|
100
|
+
return cache[propertyName];
|
|
89
101
|
};
|
|
90
102
|
}
|
|
91
103
|
});
|
|
@@ -616,11 +616,10 @@ function (_super) {
|
|
|
616
616
|
}
|
|
617
617
|
|
|
618
618
|
for (var i = 0; i < PROPAGATION_LIMIT && target !== this.rootTarget; i++) {
|
|
619
|
-
if (Node.isNode(target) && !target.parentNode) {
|
|
620
|
-
|
|
621
|
-
}
|
|
622
|
-
|
|
623
|
-
if (Node.isNode(target)) {
|
|
619
|
+
// if (Node.isNode(target) && !target.parentNode) {
|
|
620
|
+
// throw new Error('Cannot find propagation path to disconnected target');
|
|
621
|
+
// }
|
|
622
|
+
if (Node.isNode(target) && target.parentNode) {
|
|
624
623
|
// [target, parent, parent, root]
|
|
625
624
|
propagationPath.push(target.parentNode);
|
|
626
625
|
target = target.parentNode;
|
|
@@ -22,6 +22,7 @@ export interface PickingResult {
|
|
|
22
22
|
export declare class RenderingService {
|
|
23
23
|
private renderingPluginProvider;
|
|
24
24
|
private renderingContext;
|
|
25
|
+
private sceneGraphService;
|
|
25
26
|
private inited;
|
|
26
27
|
hooks: {
|
|
27
28
|
init: AsyncSeriesHook<[], import("tapable").UnsetAdditionalOptions>;
|
|
@@ -3,7 +3,7 @@ import { inject, singleton, contrib, Syringe, Contribution } from 'mana-syringe'
|
|
|
3
3
|
import { SyncHook, SyncWaterfallHook, AsyncSeriesHook, AsyncSeriesWaterfallHook } from 'tapable';
|
|
4
4
|
import { Renderable, Sortable } from '../components';
|
|
5
5
|
import { RenderingContext, RENDER_REASON } from './RenderingContext';
|
|
6
|
-
import { sortByZIndex } from './SceneGraphService';
|
|
6
|
+
import { SceneGraphService, sortByZIndex } from './SceneGraphService';
|
|
7
7
|
export var RenderingPluginContribution = Syringe.defineToken('RenderingPluginContribution');
|
|
8
8
|
/**
|
|
9
9
|
* Use frame renderer implemented by `g-canvas/svg/webgl`, in every frame we do followings:
|
|
@@ -73,6 +73,8 @@ function () {
|
|
|
73
73
|
};
|
|
74
74
|
|
|
75
75
|
RenderingService.prototype.render = function () {
|
|
76
|
+
this.sceneGraphService.syncHierarchy(this.renderingContext.root);
|
|
77
|
+
|
|
76
78
|
if (this.renderingContext.renderReasons.size && this.inited) {
|
|
77
79
|
this.renderDisplayObject(this.renderingContext.root);
|
|
78
80
|
|
|
@@ -138,6 +140,8 @@ function () {
|
|
|
138
140
|
|
|
139
141
|
__decorate([inject(RenderingContext), __metadata("design:type", Object)], RenderingService.prototype, "renderingContext", void 0);
|
|
140
142
|
|
|
143
|
+
__decorate([inject(SceneGraphService), __metadata("design:type", Object)], RenderingService.prototype, "sceneGraphService", void 0);
|
|
144
|
+
|
|
141
145
|
RenderingService = __decorate([singleton()], RenderingService);
|
|
142
146
|
return RenderingService;
|
|
143
147
|
}();
|
|
@@ -37,6 +37,7 @@ export interface SceneGraphService {
|
|
|
37
37
|
getLocalBounds(element: INode, render?: boolean): AABB | null;
|
|
38
38
|
getGeometryBounds(element: INode, render?: boolean): AABB | null;
|
|
39
39
|
getBoundingClientRect(element: INode): Rectangle;
|
|
40
|
+
syncHierarchy(element: INode): void;
|
|
40
41
|
}
|
|
41
42
|
/**
|
|
42
43
|
* update transform in scene graph
|
|
@@ -142,5 +143,8 @@ export declare class DefaultSceneGraphService implements SceneGraphService {
|
|
|
142
143
|
getLocalBounds(element: INode): AABB | null;
|
|
143
144
|
getBoundingClientRect(element: INode): Rectangle;
|
|
144
145
|
private dirtifyWorldInternal;
|
|
145
|
-
|
|
146
|
+
syncHierarchy(element: INode): void;
|
|
147
|
+
private sync;
|
|
148
|
+
private updateGraphDepth;
|
|
149
|
+
private unfreezeParentToRoot;
|
|
146
150
|
}
|
|
@@ -369,11 +369,16 @@ function () {
|
|
|
369
369
|
sortable.dirty = true;
|
|
370
370
|
}
|
|
371
371
|
|
|
372
|
+
this.updateGraphDepth(child);
|
|
372
373
|
var transform = entity.getComponent(Transform);
|
|
373
374
|
|
|
374
375
|
if (transform) {
|
|
375
376
|
this.dirtifyWorld(child, transform);
|
|
376
377
|
}
|
|
378
|
+
|
|
379
|
+
if (transform.frozen) {
|
|
380
|
+
this.unfreezeParentToRoot(child);
|
|
381
|
+
}
|
|
377
382
|
};
|
|
378
383
|
|
|
379
384
|
DefaultSceneGraphService.prototype.detach = function (child) {
|
|
@@ -530,6 +535,10 @@ function () {
|
|
|
530
535
|
};
|
|
531
536
|
|
|
532
537
|
DefaultSceneGraphService.prototype.dirtifyWorld = function (element, transform) {
|
|
538
|
+
if (!transform.dirtyFlag) {
|
|
539
|
+
this.unfreezeParentToRoot(element);
|
|
540
|
+
}
|
|
541
|
+
|
|
533
542
|
this.dirtifyWorldInternal(element, transform);
|
|
534
543
|
};
|
|
535
544
|
|
|
@@ -553,10 +562,6 @@ function () {
|
|
|
553
562
|
transform = element.entity.getComponent(Transform);
|
|
554
563
|
}
|
|
555
564
|
|
|
556
|
-
if (!transform) {
|
|
557
|
-
return mat4.create();
|
|
558
|
-
}
|
|
559
|
-
|
|
560
565
|
if (!transform.localDirtyFlag && !transform.dirtyFlag) {
|
|
561
566
|
return transform.worldTransform;
|
|
562
567
|
}
|
|
@@ -565,7 +570,7 @@ function () {
|
|
|
565
570
|
this.getWorldTransform(element.parentNode);
|
|
566
571
|
}
|
|
567
572
|
|
|
568
|
-
this.
|
|
573
|
+
this.sync(element, transform);
|
|
569
574
|
return transform.worldTransform;
|
|
570
575
|
};
|
|
571
576
|
|
|
@@ -761,13 +766,14 @@ function () {
|
|
|
761
766
|
|
|
762
767
|
if (!transform.dirtyFlag) {
|
|
763
768
|
transform.dirtyFlag = true;
|
|
769
|
+
transform.frozen = false;
|
|
764
770
|
element.childNodes.forEach(function (child) {
|
|
765
771
|
var childTransform = child.entity.getComponent(Transform);
|
|
766
772
|
|
|
767
773
|
if (!childTransform.dirtyFlag) {
|
|
768
774
|
_this.dirtifyWorldInternal(child, childTransform);
|
|
769
775
|
}
|
|
770
|
-
}); // emit on leaf node
|
|
776
|
+
}); // FIXME: emit on leaf node
|
|
771
777
|
|
|
772
778
|
if (element.childNodes.length === 0) {
|
|
773
779
|
dirtifyRenderable(element);
|
|
@@ -775,9 +781,30 @@ function () {
|
|
|
775
781
|
}
|
|
776
782
|
};
|
|
777
783
|
|
|
778
|
-
DefaultSceneGraphService.prototype.
|
|
784
|
+
DefaultSceneGraphService.prototype.syncHierarchy = function (element) {
|
|
785
|
+
var transform = element.entity.getComponent(Transform);
|
|
786
|
+
|
|
787
|
+
if (transform.frozen) {
|
|
788
|
+
return;
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
transform.frozen = true;
|
|
792
|
+
|
|
793
|
+
if (transform.localDirtyFlag || transform.dirtyFlag) {
|
|
794
|
+
this.sync(element, transform);
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
var children = element.childNodes;
|
|
798
|
+
|
|
799
|
+
for (var i = 0; i < children.length; i++) {
|
|
800
|
+
this.syncHierarchy(children[i]);
|
|
801
|
+
}
|
|
802
|
+
};
|
|
803
|
+
|
|
804
|
+
DefaultSceneGraphService.prototype.sync = function (element, transform) {
|
|
779
805
|
if (transform.localDirtyFlag) {
|
|
780
|
-
|
|
806
|
+
mat4.fromRotationTranslationScaleOrigin(transform.localTransform, transform.localRotation, transform.localPosition, transform.localScale, transform.origin);
|
|
807
|
+
transform.localDirtyFlag = false;
|
|
781
808
|
}
|
|
782
809
|
|
|
783
810
|
if (transform.dirtyFlag) {
|
|
@@ -791,8 +818,36 @@ function () {
|
|
|
791
818
|
// @see https://github.com/playcanvas/engine/issues/1077#issuecomment-359765557
|
|
792
819
|
mat4.multiply(transform.worldTransform, parentTransform.worldTransform, transform.localTransform);
|
|
793
820
|
}
|
|
821
|
+
}
|
|
822
|
+
};
|
|
823
|
+
|
|
824
|
+
DefaultSceneGraphService.prototype.updateGraphDepth = function (element) {
|
|
825
|
+
var transform = element.entity.getComponent(Transform);
|
|
826
|
+
|
|
827
|
+
if (element.parentNode) {
|
|
828
|
+
transform.graphDepth = element.parentNode.entity.getComponent(Transform).graphDepth + 1;
|
|
829
|
+
} else {
|
|
830
|
+
transform.graphDepth = 0;
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
var children = element.childNodes;
|
|
834
|
+
|
|
835
|
+
for (var i = 0; i < children.length; i++) {
|
|
836
|
+
this.updateGraphDepth(children[i]);
|
|
837
|
+
}
|
|
838
|
+
};
|
|
839
|
+
|
|
840
|
+
DefaultSceneGraphService.prototype.unfreezeParentToRoot = function (child) {
|
|
841
|
+
var p = child.parentNode;
|
|
842
|
+
|
|
843
|
+
while (p) {
|
|
844
|
+
var transform = p.entity.getComponent(Transform);
|
|
845
|
+
|
|
846
|
+
if (transform) {
|
|
847
|
+
transform.frozen = false;
|
|
848
|
+
}
|
|
794
849
|
|
|
795
|
-
|
|
850
|
+
p = p.parentNode;
|
|
796
851
|
}
|
|
797
852
|
};
|
|
798
853
|
|
|
@@ -16,10 +16,7 @@ export interface CustomElement<CustomElementStyleProps> {
|
|
|
16
16
|
* @see https://yuque.antfin-inc.com/antv/czqvg5/pgqipg
|
|
17
17
|
*/
|
|
18
18
|
export declare abstract class CustomElement<CustomElementStyleProps> extends DisplayObject<CustomElementStyleProps> {
|
|
19
|
-
private shadowNodes;
|
|
20
19
|
constructor(config: DisplayObjectConfig<CustomElementStyleProps>);
|
|
21
20
|
private handleMounted;
|
|
22
|
-
private handleChildInserted;
|
|
23
|
-
private handleChildRemoved;
|
|
24
21
|
private handleAttributeChanged;
|
|
25
22
|
}
|
|
@@ -18,39 +18,34 @@ var _interfaces = require("../dom/interfaces");
|
|
|
18
18
|
var CustomElement =
|
|
19
19
|
/** @class */
|
|
20
20
|
function (_super) {
|
|
21
|
-
(0, _tslib.__extends)(CustomElement, _super);
|
|
21
|
+
(0, _tslib.__extends)(CustomElement, _super); // private shadowNodes: DisplayObject[] = [];
|
|
22
22
|
|
|
23
23
|
function CustomElement(config) {
|
|
24
24
|
var _this = _super.call(this, config) || this;
|
|
25
25
|
|
|
26
|
-
_this.shadowNodes = [];
|
|
27
|
-
|
|
28
26
|
_this.handleMounted = function () {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
});
|
|
34
|
-
|
|
27
|
+
// this.shadowNodes.forEach((node) => {
|
|
28
|
+
// // every child and its children should turn into a shadow node
|
|
29
|
+
// // a shadow node doesn't mean to be unrenderable, it's just unsearchable in scenegraph
|
|
30
|
+
// node.shadow = true;
|
|
31
|
+
// });
|
|
35
32
|
if (_this.connectedCallback) {
|
|
36
33
|
_this.connectedCallback();
|
|
37
34
|
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
});
|
|
53
|
-
};
|
|
35
|
+
}; // private handleChildInserted = (e: FederatedEvent) => {
|
|
36
|
+
// (e.target as DisplayObject).forEach((node) => {
|
|
37
|
+
// // append children like other shapes after mounted
|
|
38
|
+
// if (!this.isConnected) {
|
|
39
|
+
// this.shadowNodes.push(node as DisplayObject);
|
|
40
|
+
// }
|
|
41
|
+
// });
|
|
42
|
+
// };
|
|
43
|
+
// private handleChildRemoved = (e: FederatedEvent) => {
|
|
44
|
+
// (e.target as DisplayObject).forEach((node) => {
|
|
45
|
+
// node.shadow = false;
|
|
46
|
+
// });
|
|
47
|
+
// };
|
|
48
|
+
|
|
54
49
|
|
|
55
50
|
_this.handleAttributeChanged = function (e) {
|
|
56
51
|
// only listen itself
|
|
@@ -64,11 +59,9 @@ function (_super) {
|
|
|
64
59
|
oldValue = _a.oldValue,
|
|
65
60
|
newValue = _a.newValue;
|
|
66
61
|
_this.attributeChangedCallback && _this.attributeChangedCallback(attributeName, oldValue, newValue);
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
_this.addEventListener(_interfaces.ElementEvent.CHILD_INSERTED, _this.handleChildInserted);
|
|
62
|
+
}; // this.addEventListener(ElementEvent.CHILD_INSERTED, this.handleChildInserted);
|
|
63
|
+
// this.addEventListener(ElementEvent.CHILD_REMOVED, this.handleChildRemoved);
|
|
70
64
|
|
|
71
|
-
_this.addEventListener(_interfaces.ElementEvent.CHILD_REMOVED, _this.handleChildRemoved);
|
|
72
65
|
|
|
73
66
|
if (_this.attributeChangedCallback) {
|
|
74
67
|
_this.addEventListener(_interfaces.ElementEvent.ATTRIBUTE_CHANGED, _this.handleAttributeChanged);
|
package/lib/global-module.js
CHANGED
|
@@ -60,12 +60,15 @@ var containerModule = (0, _manaSyringe.Module)(function (register) {
|
|
|
60
60
|
register({
|
|
61
61
|
token: _aabb.GeometryUpdaterFactory,
|
|
62
62
|
useFactory: function useFactory(context) {
|
|
63
|
+
var cache = {};
|
|
63
64
|
return function (tagName) {
|
|
64
|
-
if (
|
|
65
|
-
|
|
65
|
+
if (!cache[tagName]) {
|
|
66
|
+
if (context.container.isBoundNamed(_aabb.GeometryAABBUpdater, tagName)) {
|
|
67
|
+
cache[tagName] = context.container.getNamed(_aabb.GeometryAABBUpdater, tagName);
|
|
68
|
+
}
|
|
66
69
|
}
|
|
67
70
|
|
|
68
|
-
return
|
|
71
|
+
return cache[tagName];
|
|
69
72
|
};
|
|
70
73
|
}
|
|
71
74
|
}); // bind style property handlers
|
|
@@ -73,36 +76,45 @@ var containerModule = (0, _manaSyringe.Module)(function (register) {
|
|
|
73
76
|
register({
|
|
74
77
|
token: _propertyHandlers.StylePropertyParserFactory,
|
|
75
78
|
useFactory: function useFactory(context) {
|
|
79
|
+
var cache = {};
|
|
76
80
|
return function (propertyName) {
|
|
77
|
-
if (
|
|
78
|
-
|
|
81
|
+
if (!cache[propertyName]) {
|
|
82
|
+
if (context.container.isBoundNamed(_propertyHandlers.StylePropertyParser, propertyName)) {
|
|
83
|
+
cache[propertyName] = context.container.getNamed(_propertyHandlers.StylePropertyParser, propertyName);
|
|
84
|
+
}
|
|
79
85
|
}
|
|
80
86
|
|
|
81
|
-
return
|
|
87
|
+
return cache[propertyName];
|
|
82
88
|
};
|
|
83
89
|
}
|
|
84
90
|
});
|
|
85
91
|
register({
|
|
86
92
|
token: _propertyHandlers.StylePropertyUpdaterFactory,
|
|
87
93
|
useFactory: function useFactory(context) {
|
|
94
|
+
var cache = {};
|
|
88
95
|
return function (propertyName) {
|
|
89
|
-
if (
|
|
90
|
-
|
|
96
|
+
if (!cache[propertyName]) {
|
|
97
|
+
if (context.container.isBoundNamed(_propertyHandlers.StylePropertyUpdater, propertyName)) {
|
|
98
|
+
cache[propertyName] = context.container.getAllNamed(_propertyHandlers.StylePropertyUpdater, propertyName);
|
|
99
|
+
}
|
|
91
100
|
}
|
|
92
101
|
|
|
93
|
-
return
|
|
102
|
+
return cache[propertyName];
|
|
94
103
|
};
|
|
95
104
|
}
|
|
96
105
|
});
|
|
97
106
|
register({
|
|
98
107
|
token: _propertyHandlers.StylePropertyMergerFactory,
|
|
99
108
|
useFactory: function useFactory(context) {
|
|
109
|
+
var cache = {};
|
|
100
110
|
return function (propertyName) {
|
|
101
|
-
if (
|
|
102
|
-
|
|
111
|
+
if (!cache[propertyName]) {
|
|
112
|
+
if (context.container.isBoundNamed(_propertyHandlers.StylePropertyMerger, propertyName)) {
|
|
113
|
+
cache[propertyName] = context.container.getNamed(_propertyHandlers.StylePropertyMerger, propertyName);
|
|
114
|
+
}
|
|
103
115
|
}
|
|
104
116
|
|
|
105
|
-
return
|
|
117
|
+
return cache[propertyName];
|
|
106
118
|
};
|
|
107
119
|
}
|
|
108
120
|
});
|
|
@@ -644,11 +644,10 @@ function (_super) {
|
|
|
644
644
|
}
|
|
645
645
|
|
|
646
646
|
for (var i = 0; i < PROPAGATION_LIMIT && target !== this.rootTarget; i++) {
|
|
647
|
-
if (
|
|
648
|
-
|
|
649
|
-
}
|
|
650
|
-
|
|
651
|
-
if (_Node.Node.isNode(target)) {
|
|
647
|
+
// if (Node.isNode(target) && !target.parentNode) {
|
|
648
|
+
// throw new Error('Cannot find propagation path to disconnected target');
|
|
649
|
+
// }
|
|
650
|
+
if (_Node.Node.isNode(target) && target.parentNode) {
|
|
652
651
|
// [target, parent, parent, root]
|
|
653
652
|
propagationPath.push(target.parentNode);
|
|
654
653
|
target = target.parentNode;
|
|
@@ -22,6 +22,7 @@ export interface PickingResult {
|
|
|
22
22
|
export declare class RenderingService {
|
|
23
23
|
private renderingPluginProvider;
|
|
24
24
|
private renderingContext;
|
|
25
|
+
private sceneGraphService;
|
|
25
26
|
private inited;
|
|
26
27
|
hooks: {
|
|
27
28
|
init: AsyncSeriesHook<[], import("tapable").UnsetAdditionalOptions>;
|
|
@@ -89,6 +89,8 @@ function () {
|
|
|
89
89
|
};
|
|
90
90
|
|
|
91
91
|
RenderingService.prototype.render = function () {
|
|
92
|
+
this.sceneGraphService.syncHierarchy(this.renderingContext.root);
|
|
93
|
+
|
|
92
94
|
if (this.renderingContext.renderReasons.size && this.inited) {
|
|
93
95
|
this.renderDisplayObject(this.renderingContext.root);
|
|
94
96
|
|
|
@@ -152,6 +154,7 @@ function () {
|
|
|
152
154
|
|
|
153
155
|
(0, _tslib.__decorate)([(0, _manaSyringe.contrib)(RenderingPluginContribution), (0, _tslib.__metadata)("design:type", Object)], RenderingService.prototype, "renderingPluginProvider", void 0);
|
|
154
156
|
(0, _tslib.__decorate)([(0, _manaSyringe.inject)(_RenderingContext.RenderingContext), (0, _tslib.__metadata)("design:type", Object)], RenderingService.prototype, "renderingContext", void 0);
|
|
157
|
+
(0, _tslib.__decorate)([(0, _manaSyringe.inject)(_SceneGraphService.SceneGraphService), (0, _tslib.__metadata)("design:type", Object)], RenderingService.prototype, "sceneGraphService", void 0);
|
|
155
158
|
RenderingService = (0, _tslib.__decorate)([(0, _manaSyringe.singleton)()], RenderingService);
|
|
156
159
|
return RenderingService;
|
|
157
160
|
}();
|
|
@@ -37,6 +37,7 @@ export interface SceneGraphService {
|
|
|
37
37
|
getLocalBounds(element: INode, render?: boolean): AABB | null;
|
|
38
38
|
getGeometryBounds(element: INode, render?: boolean): AABB | null;
|
|
39
39
|
getBoundingClientRect(element: INode): Rectangle;
|
|
40
|
+
syncHierarchy(element: INode): void;
|
|
40
41
|
}
|
|
41
42
|
/**
|
|
42
43
|
* update transform in scene graph
|
|
@@ -142,5 +143,8 @@ export declare class DefaultSceneGraphService implements SceneGraphService {
|
|
|
142
143
|
getLocalBounds(element: INode): AABB | null;
|
|
143
144
|
getBoundingClientRect(element: INode): Rectangle;
|
|
144
145
|
private dirtifyWorldInternal;
|
|
145
|
-
|
|
146
|
+
syncHierarchy(element: INode): void;
|
|
147
|
+
private sync;
|
|
148
|
+
private updateGraphDepth;
|
|
149
|
+
private unfreezeParentToRoot;
|
|
146
150
|
}
|