@antv/g 5.0.15 → 5.0.18
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.min.js +18 -2
- package/es/Canvas.d.ts +7 -1
- package/es/Canvas.js +9 -10
- package/es/camera/Camera.d.ts +3 -2
- package/es/camera/Camera.js +16 -8
- package/es/canvas-module.js +4 -2
- package/es/components/Transform.d.ts +0 -1
- package/es/components/Transform.js +0 -1
- package/es/display-objects/Circle.d.ts +1 -1
- package/es/display-objects/Circle.js +8 -3
- package/es/display-objects/CustomElement.d.ts +3 -2
- package/es/display-objects/CustomElement.js +9 -6
- package/es/display-objects/DisplayObject.d.ts +9 -3
- package/es/display-objects/DisplayObject.js +97 -50
- package/es/display-objects/Ellipse.d.ts +1 -1
- package/es/display-objects/Ellipse.js +8 -3
- package/es/display-objects/Group.d.ts +18 -2
- package/es/display-objects/Group.js +11 -9
- package/es/display-objects/HTML.d.ts +1 -1
- package/es/display-objects/HTML.js +9 -4
- package/es/display-objects/Image.d.ts +5 -3
- package/es/display-objects/Image.js +8 -3
- package/es/display-objects/Line.d.ts +1 -1
- package/es/display-objects/Line.js +12 -4
- package/es/display-objects/Path.d.ts +3 -2
- package/es/display-objects/Path.js +10 -5
- package/es/display-objects/Polygon.d.ts +1 -1
- package/es/display-objects/Polygon.js +9 -3
- package/es/display-objects/Polyline.d.ts +1 -1
- package/es/display-objects/Polyline.js +10 -5
- package/es/display-objects/Rect.d.ts +1 -1
- package/es/display-objects/Rect.js +8 -3
- package/es/display-objects/Text.d.ts +32 -4
- package/es/display-objects/Text.js +70 -10
- package/es/dom/Animation.js +2 -2
- package/es/dom/AnimationTimeline.js +1 -2
- package/es/dom/CustomElementRegistry.js +12 -12
- package/es/dom/Document.d.ts +2 -1
- package/es/dom/Document.js +22 -2
- package/es/dom/Element.d.ts +38 -5
- package/es/dom/Element.js +115 -16
- package/es/dom/EventTarget.d.ts +2 -2
- package/es/dom/EventTarget.js +4 -3
- package/es/dom/FederatedEvent.d.ts +4 -1
- package/es/dom/KeyframeList.js +1 -1
- package/es/dom/MutationEvent.d.ts +15 -0
- package/es/dom/MutationEvent.js +29 -0
- package/es/dom/MutationObserver.d.ts +36 -0
- package/es/dom/MutationObserver.js +413 -0
- package/es/dom/MutationRecord.d.ts +14 -0
- package/es/dom/MutationRecord.js +31 -0
- package/es/dom/Node.d.ts +35 -3
- package/es/dom/Node.js +184 -17
- package/es/dom/index.d.ts +3 -0
- package/es/dom/index.js +3 -0
- package/es/dom/interfaces.d.ts +39 -8
- package/es/dom/interfaces.js +23 -5
- package/es/global-module.d.ts +1 -0
- package/es/global-module.js +11 -13
- package/es/index.d.ts +1 -0
- package/es/index.js +1 -0
- package/es/plugins/CullingPlugin.d.ts +0 -2
- package/es/plugins/CullingPlugin.js +3 -24
- package/es/plugins/DirtyCheckPlugin.js +2 -2
- package/es/plugins/EventPlugin.d.ts +1 -0
- package/es/plugins/EventPlugin.js +15 -5
- package/es/plugins/FrustumCullingStrategy.d.ts +1 -0
- package/es/plugins/FrustumCullingStrategy.js +41 -33
- package/es/plugins/PrepareRendererPlugin.js +21 -5
- package/es/property-handlers/aabb.js +19 -20
- package/es/property-handlers/color.js +5 -2
- package/es/property-handlers/dimension.d.ts +15 -3
- package/es/property-handlers/dimension.js +50 -9
- package/es/property-handlers/index.d.ts +3 -0
- package/es/property-handlers/index.js +4 -1
- package/es/property-handlers/inherit.d.ts +6 -0
- package/es/property-handlers/inherit.js +25 -0
- package/es/property-handlers/interfaces.d.ts +2 -2
- package/es/property-handlers/lineDash.d.ts +6 -1
- package/es/property-handlers/lineDash.js +23 -4
- package/es/property-handlers/offsetDistance.js +2 -2
- package/es/property-handlers/text.d.ts +2 -0
- package/es/property-handlers/text.js +3 -0
- package/es/property-handlers/textTransform.d.ts +6 -0
- package/es/property-handlers/textTransform.js +19 -0
- package/es/services/EventService.js +11 -7
- package/es/services/RenderingContext.d.ts +5 -8
- package/es/services/RenderingContext.js +6 -7
- package/es/services/RenderingService.d.ts +12 -2
- package/es/services/RenderingService.js +23 -12
- package/es/services/SceneGraphSelector.d.ts +3 -2
- package/es/services/SceneGraphSelector.js +8 -4
- package/es/services/SceneGraphService.d.ts +0 -7
- package/es/services/SceneGraphService.js +17 -87
- package/es/services/aabb/CircleUpdater.js +3 -3
- package/es/services/aabb/EllipseUpdater.js +2 -2
- package/es/services/aabb/LineUpdater.js +2 -2
- package/es/services/aabb/PathUpdater.js +2 -2
- package/es/services/aabb/PolylineUpdater.js +3 -3
- package/es/services/aabb/RectUpdater.js +4 -4
- package/es/services/aabb/TextUpdater.js +31 -10
- package/es/services/text/index.js +19 -21
- package/es/shapes/AABB.js +5 -0
- package/es/types.d.ts +48 -24
- package/es/types.js +50 -31
- package/es/utils/animation.js +1 -1
- package/es/utils/custom-easing.js +1 -1
- package/es/utils/event.js +7 -4
- package/es/utils/index.d.ts +2 -0
- package/es/utils/index.js +3 -1
- package/es/utils/interpolation.d.ts +1 -0
- package/es/utils/interpolation.js +41 -8
- package/es/utils/path.js +11 -11
- package/es/utils/raf.d.ts +1 -1
- package/es/utils/raf.js +0 -2
- package/es/utils/string.d.ts +1 -0
- package/es/utils/string.js +9 -0
- package/es/utils/text.js +3 -3
- package/lib/Canvas.d.ts +7 -1
- package/lib/Canvas.js +7 -8
- package/lib/camera/Camera.d.ts +3 -2
- package/lib/camera/Camera.js +20 -10
- package/lib/canvas-module.js +3 -1
- package/lib/components/Transform.d.ts +0 -1
- package/lib/components/Transform.js +0 -1
- package/lib/display-objects/Circle.d.ts +1 -1
- package/lib/display-objects/Circle.js +7 -2
- package/lib/display-objects/CustomElement.d.ts +3 -2
- package/lib/display-objects/CustomElement.js +9 -6
- package/lib/display-objects/DisplayObject.d.ts +9 -3
- package/lib/display-objects/DisplayObject.js +97 -47
- package/lib/display-objects/Ellipse.d.ts +1 -1
- package/lib/display-objects/Ellipse.js +7 -2
- package/lib/display-objects/Group.d.ts +18 -2
- package/lib/display-objects/Group.js +10 -9
- package/lib/display-objects/HTML.d.ts +1 -1
- package/lib/display-objects/HTML.js +8 -4
- package/lib/display-objects/Image.d.ts +5 -3
- package/lib/display-objects/Image.js +7 -2
- package/lib/display-objects/Line.d.ts +1 -1
- package/lib/display-objects/Line.js +11 -3
- package/lib/display-objects/Path.d.ts +3 -2
- package/lib/display-objects/Path.js +9 -4
- package/lib/display-objects/Polygon.d.ts +1 -1
- package/lib/display-objects/Polygon.js +8 -2
- package/lib/display-objects/Polyline.d.ts +1 -1
- package/lib/display-objects/Polyline.js +9 -4
- package/lib/display-objects/Rect.d.ts +1 -1
- package/lib/display-objects/Rect.js +7 -2
- package/lib/display-objects/Text.d.ts +32 -4
- package/lib/display-objects/Text.js +69 -9
- package/lib/dom/Animation.js +2 -2
- package/lib/dom/AnimationTimeline.js +1 -2
- package/lib/dom/CustomElementRegistry.js +11 -11
- package/lib/dom/Document.d.ts +2 -1
- package/lib/dom/Document.js +24 -3
- package/lib/dom/Element.d.ts +38 -5
- package/lib/dom/Element.js +117 -16
- package/lib/dom/EventTarget.d.ts +2 -2
- package/lib/dom/EventTarget.js +4 -3
- package/lib/dom/FederatedEvent.d.ts +4 -1
- package/lib/dom/KeyframeList.js +1 -1
- package/lib/dom/MutationEvent.d.ts +15 -0
- package/lib/dom/MutationEvent.js +37 -0
- package/lib/dom/MutationObserver.d.ts +36 -0
- package/lib/dom/MutationObserver.js +424 -0
- package/lib/dom/MutationRecord.d.ts +14 -0
- package/lib/dom/MutationRecord.js +38 -0
- package/lib/dom/Node.d.ts +35 -3
- package/lib/dom/Node.js +185 -16
- package/lib/dom/index.d.ts +3 -0
- package/lib/dom/index.js +39 -0
- package/lib/dom/interfaces.d.ts +39 -8
- package/lib/dom/interfaces.js +23 -5
- package/lib/global-module.d.ts +1 -0
- package/lib/global-module.js +12 -8
- package/lib/index.d.ts +1 -0
- package/lib/index.js +3 -1
- package/lib/plugins/CullingPlugin.d.ts +0 -2
- package/lib/plugins/CullingPlugin.js +2 -23
- package/lib/plugins/DirtyCheckPlugin.js +1 -1
- package/lib/plugins/EventPlugin.d.ts +1 -0
- package/lib/plugins/EventPlugin.js +13 -5
- package/lib/plugins/FrustumCullingStrategy.d.ts +1 -0
- package/lib/plugins/FrustumCullingStrategy.js +42 -33
- package/lib/plugins/PrepareRendererPlugin.js +24 -4
- package/lib/property-handlers/aabb.js +18 -19
- package/lib/property-handlers/color.js +6 -3
- package/lib/property-handlers/dimension.d.ts +15 -3
- package/lib/property-handlers/dimension.js +50 -8
- package/lib/property-handlers/index.d.ts +3 -0
- package/lib/property-handlers/index.js +39 -0
- package/lib/property-handlers/inherit.d.ts +6 -0
- package/lib/property-handlers/inherit.js +34 -0
- package/lib/property-handlers/interfaces.d.ts +2 -2
- package/lib/property-handlers/lineDash.d.ts +6 -1
- package/lib/property-handlers/lineDash.js +25 -4
- package/lib/property-handlers/offsetDistance.js +1 -1
- package/lib/property-handlers/text.d.ts +2 -0
- package/lib/property-handlers/text.js +10 -0
- package/lib/property-handlers/textTransform.d.ts +6 -0
- package/lib/property-handlers/textTransform.js +27 -0
- package/lib/services/EventService.js +11 -7
- package/lib/services/RenderingContext.d.ts +5 -8
- package/lib/services/RenderingContext.js +8 -9
- package/lib/services/RenderingService.d.ts +12 -2
- package/lib/services/RenderingService.js +23 -11
- package/lib/services/SceneGraphSelector.d.ts +3 -2
- package/lib/services/SceneGraphSelector.js +10 -3
- package/lib/services/SceneGraphService.d.ts +0 -7
- package/lib/services/SceneGraphService.js +18 -91
- package/lib/services/aabb/CircleUpdater.js +2 -2
- package/lib/services/aabb/EllipseUpdater.js +1 -1
- package/lib/services/aabb/LineUpdater.js +1 -1
- package/lib/services/aabb/PathUpdater.js +1 -1
- package/lib/services/aabb/PolylineUpdater.js +2 -2
- package/lib/services/aabb/RectUpdater.js +3 -3
- package/lib/services/aabb/TextUpdater.js +30 -9
- package/lib/services/text/index.js +19 -21
- package/lib/shapes/AABB.js +5 -0
- package/lib/types.d.ts +48 -24
- package/lib/types.js +56 -35
- package/lib/utils/animation.js +1 -1
- package/lib/utils/custom-easing.js +1 -1
- package/lib/utils/event.js +7 -4
- package/lib/utils/index.d.ts +2 -0
- package/lib/utils/index.js +26 -0
- package/lib/utils/interpolation.d.ts +1 -0
- package/lib/utils/interpolation.js +43 -7
- package/lib/utils/path.js +10 -10
- package/lib/utils/raf.d.ts +1 -1
- package/lib/utils/raf.js +0 -2
- package/lib/utils/string.d.ts +1 -0
- package/lib/utils/string.js +16 -0
- package/lib/utils/text.js +3 -3
- package/package.json +5 -3
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { TextTransform } from '../types';
|
|
2
|
+
import { Shape } from '..';
|
|
3
|
+
/**
|
|
4
|
+
* @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/text-transform
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export function updateTextTransform(oldTextTransform, newTextTransform, o) {
|
|
8
|
+
if (o.nodeName === Shape.TEXT) {
|
|
9
|
+
var object = o;
|
|
10
|
+
|
|
11
|
+
if (newTextTransform === TextTransform.CAPITALIZE) {
|
|
12
|
+
object.style.text = object.style.text.charAt(0).toUpperCase() + object.style.text.slice(1);
|
|
13
|
+
} else if (newTextTransform === TextTransform.LOWERCASE) {
|
|
14
|
+
object.style.text = object.style.text.toLowerCase();
|
|
15
|
+
} else if (newTextTransform === TextTransform.UPPERCASE) {
|
|
16
|
+
object.style.text = object.style.text.toUpperCase(); // } else if (newTextTransform === TextTransform.NONE) {
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -149,10 +149,8 @@ function (_super) {
|
|
|
149
149
|
clickHistory.timeStamp = now;
|
|
150
150
|
clickEvent.detail = clickHistory.clickCount;
|
|
151
151
|
|
|
152
|
-
if (clickEvent.pointerType === 'mouse') {
|
|
152
|
+
if (clickEvent.pointerType === 'mouse' || clickEvent.pointerType === 'touch') {
|
|
153
153
|
this.dispatchEvent(clickEvent, 'click');
|
|
154
|
-
} else if (clickEvent.pointerType === 'touch') {
|
|
155
|
-
this.dispatchEvent(clickEvent, 'tap');
|
|
156
154
|
} else {
|
|
157
155
|
this.dispatchEvent(clickEvent, 'pointertap');
|
|
158
156
|
}
|
|
@@ -479,6 +477,12 @@ function (_super) {
|
|
|
479
477
|
}
|
|
480
478
|
|
|
481
479
|
EventService.prototype.init = function () {
|
|
480
|
+
// this.onPointerDown = this.onPointerDown.bind(this);
|
|
481
|
+
// this.onPointerMove = this.onPointerUp.bind(this);
|
|
482
|
+
// this.onPointerMove = this.onPointerMove.bind(this);
|
|
483
|
+
// this.onPointerUp = this.onPointerUp.bind(this);
|
|
484
|
+
// this.onPointerOut = this.onPointerOut.bind(this);
|
|
485
|
+
// this.onWheel = this.onWheel.bind(this);
|
|
482
486
|
this.rootTarget = this.renderingContext.root.parentNode; // document
|
|
483
487
|
|
|
484
488
|
this.addEventMapping('pointerdown', this.onPointerDown);
|
|
@@ -563,7 +567,7 @@ function (_super) {
|
|
|
563
567
|
mappers[i].fn(e);
|
|
564
568
|
}
|
|
565
569
|
} else {
|
|
566
|
-
console.warn("[EventService]: Event mapping not defined for "
|
|
570
|
+
console.warn("[EventService]: Event mapping not defined for ".concat(e.type));
|
|
567
571
|
}
|
|
568
572
|
};
|
|
569
573
|
|
|
@@ -853,7 +857,7 @@ function (_super) {
|
|
|
853
857
|
|
|
854
858
|
EventService.prototype.notifyTarget = function (e, type) {
|
|
855
859
|
type = type !== null && type !== void 0 ? type : e.type;
|
|
856
|
-
var key = e.eventPhase === e.CAPTURING_PHASE || e.eventPhase === e.AT_TARGET ? type
|
|
860
|
+
var key = e.eventPhase === e.CAPTURING_PHASE || e.eventPhase === e.AT_TARGET ? "".concat(type, "capture") : type;
|
|
857
861
|
this.notifyListeners(e, key);
|
|
858
862
|
|
|
859
863
|
if (e.eventPhase === e.AT_TARGET) {
|
|
@@ -873,14 +877,14 @@ function (_super) {
|
|
|
873
877
|
emitter.removeListener(type, listeners.fn, undefined, true);
|
|
874
878
|
}
|
|
875
879
|
|
|
876
|
-
listeners.fn.call(listeners.context, e);
|
|
880
|
+
listeners.fn.call(e.currentTarget || listeners.context, e); // listeners.fn.call(listeners.context, e);
|
|
877
881
|
} else {
|
|
878
882
|
for (var i = 0; i < listeners.length && !e.propagationImmediatelyStopped; i++) {
|
|
879
883
|
if (listeners[i].once) {
|
|
880
884
|
emitter.removeListener(type, listeners[i].fn, undefined, true);
|
|
881
885
|
}
|
|
882
886
|
|
|
883
|
-
listeners[i].fn.call(listeners[i].context, e);
|
|
887
|
+
listeners[i].fn.call(e.currentTarget || listeners[i].context, e); // listeners[i].fn.call(listeners[i].context, e);
|
|
884
888
|
}
|
|
885
889
|
}
|
|
886
890
|
};
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import type { Group } from '../display-objects';
|
|
2
|
-
import type { AABB } from '../shapes';
|
|
3
2
|
/**
|
|
4
3
|
* why we need re-render
|
|
5
4
|
*/
|
|
6
|
-
export declare enum
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
None = 3
|
|
5
|
+
export declare enum RenderReason {
|
|
6
|
+
CAMERA_CHANGED = 0,
|
|
7
|
+
DISPLAY_OBJECT_CHANGED = 1,
|
|
8
|
+
NONE = 2
|
|
11
9
|
}
|
|
12
10
|
export declare const RenderingContext = "RenderingContext";
|
|
13
11
|
export interface RenderingContext {
|
|
@@ -19,10 +17,9 @@ export interface RenderingContext {
|
|
|
19
17
|
* force rendering at next frame
|
|
20
18
|
*/
|
|
21
19
|
force: boolean;
|
|
22
|
-
removedRenderBoundsList: AABB[];
|
|
23
20
|
/**
|
|
24
21
|
* reason of re-render, reset after every renderred frame
|
|
25
22
|
*/
|
|
26
|
-
renderReasons: Set<
|
|
23
|
+
renderReasons: Set<RenderReason>;
|
|
27
24
|
dirty: boolean;
|
|
28
25
|
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* why we need re-render
|
|
3
3
|
*/
|
|
4
|
-
export var
|
|
4
|
+
export var RenderReason;
|
|
5
5
|
|
|
6
|
-
(function (
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
})(RENDER_REASON || (RENDER_REASON = {}));
|
|
6
|
+
(function (RenderReason) {
|
|
7
|
+
RenderReason[RenderReason["CAMERA_CHANGED"] = 0] = "CAMERA_CHANGED";
|
|
8
|
+
RenderReason[RenderReason["DISPLAY_OBJECT_CHANGED"] = 1] = "DISPLAY_OBJECT_CHANGED";
|
|
9
|
+
RenderReason[RenderReason["NONE"] = 2] = "NONE";
|
|
10
|
+
})(RenderReason || (RenderReason = {}));
|
|
12
11
|
|
|
13
12
|
export var RenderingContext = 'RenderingContext';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Syringe } from 'mana-syringe';
|
|
2
2
|
import { SyncHook, SyncWaterfallHook, AsyncParallelHook, AsyncSeriesWaterfallHook } from 'tapable';
|
|
3
|
-
import type { DisplayObject } from '..';
|
|
3
|
+
import type { CanvasConfig, DisplayObject } from '..';
|
|
4
4
|
import type { EventPosition, InteractivePointerEvent } from '../types';
|
|
5
5
|
export interface RenderingPlugin {
|
|
6
6
|
apply: (renderer: RenderingService) => void;
|
|
@@ -48,10 +48,20 @@ export declare class RenderingService {
|
|
|
48
48
|
};
|
|
49
49
|
init(): Promise<void>;
|
|
50
50
|
getStats(): {
|
|
51
|
+
/**
|
|
52
|
+
* total display objects in scenegraph
|
|
53
|
+
*/
|
|
51
54
|
total: number;
|
|
55
|
+
/**
|
|
56
|
+
* number of display objects need to render in current frame
|
|
57
|
+
*/
|
|
52
58
|
rendered: number;
|
|
59
|
+
/**
|
|
60
|
+
* number of display objects displayed on screen
|
|
61
|
+
*/
|
|
62
|
+
renderedOnscreen: number;
|
|
53
63
|
};
|
|
54
|
-
render(): void;
|
|
64
|
+
render(canvasConfig: Partial<CanvasConfig>): void;
|
|
55
65
|
private renderDisplayObject;
|
|
56
66
|
destroy(): void;
|
|
57
67
|
dirtify(): void;
|
|
@@ -2,7 +2,7 @@ import { __awaiter, __decorate, __generator, __metadata } from "tslib";
|
|
|
2
2
|
import { inject, singleton, contrib, Syringe, Contribution } from 'mana-syringe';
|
|
3
3
|
import { SyncHook, SyncWaterfallHook, AsyncParallelHook, AsyncSeriesWaterfallHook } from 'tapable';
|
|
4
4
|
import { ElementEvent } from '../dom';
|
|
5
|
-
import { RenderingContext,
|
|
5
|
+
import { RenderingContext, RenderReason } from './RenderingContext';
|
|
6
6
|
import { SceneGraphService, sortByZIndex } from './SceneGraphService';
|
|
7
7
|
export var RenderingPluginContribution = Syringe.defineToken('RenderingPluginContribution');
|
|
8
8
|
/**
|
|
@@ -21,8 +21,20 @@ function () {
|
|
|
21
21
|
function RenderingService() {
|
|
22
22
|
this.inited = false;
|
|
23
23
|
this.stats = {
|
|
24
|
+
/**
|
|
25
|
+
* total display objects in scenegraph
|
|
26
|
+
*/
|
|
24
27
|
total: 0,
|
|
25
|
-
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* number of display objects need to render in current frame
|
|
31
|
+
*/
|
|
32
|
+
rendered: 0,
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* number of display objects displayed on screen
|
|
36
|
+
*/
|
|
37
|
+
renderedOnscreen: 0
|
|
26
38
|
};
|
|
27
39
|
this.zIndexCounter = 0;
|
|
28
40
|
this.hooks = {
|
|
@@ -81,7 +93,7 @@ function () {
|
|
|
81
93
|
return this.stats;
|
|
82
94
|
};
|
|
83
95
|
|
|
84
|
-
RenderingService.prototype.render = function () {
|
|
96
|
+
RenderingService.prototype.render = function (canvasConfig) {
|
|
85
97
|
this.stats.total = 0;
|
|
86
98
|
this.stats.rendered = 0;
|
|
87
99
|
this.zIndexCounter = 0;
|
|
@@ -90,18 +102,18 @@ function () {
|
|
|
90
102
|
if (this.renderingContext.renderReasons.size && this.inited) {
|
|
91
103
|
this.renderDisplayObject(this.renderingContext.root);
|
|
92
104
|
|
|
93
|
-
if (this.renderingContext.dirty) {
|
|
94
|
-
this.
|
|
95
|
-
this.renderingContext.dirty = false;
|
|
96
|
-
} else {
|
|
97
|
-
if (this.renderingContext.renderReasons.has(RENDER_REASON.DisplayObjectRemoved)) {
|
|
105
|
+
if (this.renderingContext.dirty || canvasConfig.renderer.getConfig().enableDirtyRectangleRendering && this.stats.total === 1) {
|
|
106
|
+
if (!this.renderingContext.dirty) {
|
|
98
107
|
this.hooks.beginFrame.call();
|
|
99
|
-
this.hooks.endFrame.call();
|
|
100
108
|
}
|
|
109
|
+
|
|
110
|
+
this.stats.renderedOnscreen = this.stats.rendered;
|
|
111
|
+
this.hooks.endFrame.call();
|
|
112
|
+
this.renderingContext.dirty = false;
|
|
101
113
|
}
|
|
102
114
|
|
|
103
115
|
this.renderingContext.renderReasons.clear();
|
|
104
|
-
} // console.log('
|
|
116
|
+
} // console.log('stats', this.stats);
|
|
105
117
|
|
|
106
118
|
};
|
|
107
119
|
|
|
@@ -132,7 +144,6 @@ function () {
|
|
|
132
144
|
var renderOrderChanged = false;
|
|
133
145
|
|
|
134
146
|
if (sortable.dirty) {
|
|
135
|
-
// sortable.sorted = [...(displayObject.childNodes as IElement[])].sort(sortByZIndex);
|
|
136
147
|
sortable.sorted = displayObject.childNodes.slice().sort(sortByZIndex);
|
|
137
148
|
renderOrderChanged = true;
|
|
138
149
|
sortable.dirty = false;
|
|
@@ -159,7 +170,7 @@ function () {
|
|
|
159
170
|
|
|
160
171
|
RenderingService.prototype.dirtify = function () {
|
|
161
172
|
// need re-render
|
|
162
|
-
this.renderingContext.renderReasons.add(
|
|
173
|
+
this.renderingContext.renderReasons.add(RenderReason.DISPLAY_OBJECT_CHANGED);
|
|
163
174
|
};
|
|
164
175
|
|
|
165
176
|
__decorate([contrib(RenderingPluginContribution), __metadata("design:type", Object)], RenderingService.prototype, "renderingPluginProvider", void 0);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { Syringe } from 'mana-syringe';
|
|
1
2
|
import type { IElement } from '../dom/interfaces';
|
|
2
|
-
export declare const SceneGraphSelectorFactory
|
|
3
|
-
export declare const SceneGraphSelector
|
|
3
|
+
export declare const SceneGraphSelectorFactory: Syringe.DefinedToken;
|
|
4
|
+
export declare const SceneGraphSelector: Syringe.DefinedToken;
|
|
4
5
|
export interface SceneGraphSelector {
|
|
5
6
|
selectOne: <R extends IElement, T extends IElement>(query: string, root: R) => T | null;
|
|
6
7
|
selectAll: <R extends IElement, T extends IElement>(query: string, root: R) => T[];
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { singleton } from 'mana-syringe';
|
|
3
|
-
export var SceneGraphSelectorFactory = 'SceneGraphSelectorFactory';
|
|
4
|
-
export var SceneGraphSelector = 'SceneGraphSelector'
|
|
2
|
+
import { singleton, Syringe } from 'mana-syringe';
|
|
3
|
+
export var SceneGraphSelectorFactory = Syringe.defineToken('SceneGraphSelectorFactory');
|
|
4
|
+
export var SceneGraphSelector = Syringe.defineToken('SceneGraphSelector', {
|
|
5
|
+
multiple: false
|
|
6
|
+
});
|
|
5
7
|
/**
|
|
6
8
|
* support following DOM API
|
|
7
9
|
* * getElementById
|
|
@@ -58,7 +60,9 @@ function () {
|
|
|
58
60
|
return true;
|
|
59
61
|
};
|
|
60
62
|
|
|
61
|
-
DefaultSceneGraphSelector = __decorate([singleton(
|
|
63
|
+
DefaultSceneGraphSelector = __decorate([singleton({
|
|
64
|
+
token: SceneGraphSelector
|
|
65
|
+
})], DefaultSceneGraphSelector);
|
|
62
66
|
return DefaultSceneGraphSelector;
|
|
63
67
|
}();
|
|
64
68
|
|
|
@@ -53,12 +53,6 @@ export declare class DefaultSceneGraphService implements SceneGraphService {
|
|
|
53
53
|
querySelectorAll<R extends IElement, T extends IElement>(query: string, root: R): T[];
|
|
54
54
|
attach<C extends INode, P extends INode & IParentNode>(child: C, parent: P, index?: number): void;
|
|
55
55
|
detach<C extends INode>(child: C): void;
|
|
56
|
-
/**
|
|
57
|
-
* compare two display objects by hierarchy-index and z-index
|
|
58
|
-
*
|
|
59
|
-
* use materialized path
|
|
60
|
-
* @see https://stackoverflow.com/questions/31470730/comparing-tree-nodes
|
|
61
|
-
*/
|
|
62
56
|
getOrigin(element: INode): vec3;
|
|
63
57
|
setOrigin(element: INode, origin: vec3 | number, y?: number, z?: number): void;
|
|
64
58
|
/**
|
|
@@ -147,6 +141,5 @@ export declare class DefaultSceneGraphService implements SceneGraphService {
|
|
|
147
141
|
private dirtifyWorldInternal;
|
|
148
142
|
syncHierarchy(element: INode): void;
|
|
149
143
|
private sync;
|
|
150
|
-
private updateGraphDepth;
|
|
151
144
|
private unfreezeParentToRoot;
|
|
152
145
|
}
|
|
@@ -5,6 +5,7 @@ import { mat4, quat, vec3 } from 'gl-matrix';
|
|
|
5
5
|
import { AABB, Rectangle } from '../shapes';
|
|
6
6
|
import { SceneGraphSelectorFactory } from './SceneGraphSelector';
|
|
7
7
|
import { ElementEvent } from '../dom/interfaces';
|
|
8
|
+
import { MutationEvent } from '../dom/MutationEvent';
|
|
8
9
|
export function sortByZIndex(o1, o2) {
|
|
9
10
|
var zIndex1 = Number(o1.style.zIndex);
|
|
10
11
|
var zIndex2 = Number(o2.style.zIndex);
|
|
@@ -325,9 +326,9 @@ function () {
|
|
|
325
326
|
|
|
326
327
|
if (sortable) {
|
|
327
328
|
sortable.dirty = true;
|
|
328
|
-
}
|
|
329
|
+
} // this.updateGraphDepth(child);
|
|
330
|
+
|
|
329
331
|
|
|
330
|
-
this.updateGraphDepth(child);
|
|
331
332
|
var transform = child.transformable;
|
|
332
333
|
|
|
333
334
|
if (transform) {
|
|
@@ -341,16 +342,14 @@ function () {
|
|
|
341
342
|
|
|
342
343
|
DefaultSceneGraphService.prototype.detach = function (child) {
|
|
343
344
|
if (child.parentNode) {
|
|
344
|
-
var transform = child.transformable;
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
} // parent needs re-sort
|
|
353
|
-
|
|
345
|
+
var transform = child.transformable; // if (transform) {
|
|
346
|
+
// const worldTransform = this.getWorldTransform(child, transform);
|
|
347
|
+
// mat4.getScaling(transform.localScale, worldTransform);
|
|
348
|
+
// mat4.getTranslation(transform.localPosition, worldTransform);
|
|
349
|
+
// mat4.getRotation(transform.localRotation, worldTransform);
|
|
350
|
+
// transform.localDirtyFlag = true;
|
|
351
|
+
// }
|
|
352
|
+
// parent needs re-sort
|
|
354
353
|
|
|
355
354
|
var sortable = child.parentNode.sortable;
|
|
356
355
|
|
|
@@ -371,60 +370,6 @@ function () {
|
|
|
371
370
|
child.parentNode = null;
|
|
372
371
|
}
|
|
373
372
|
};
|
|
374
|
-
/**
|
|
375
|
-
* compare two display objects by hierarchy-index and z-index
|
|
376
|
-
*
|
|
377
|
-
* use materialized path
|
|
378
|
-
* @see https://stackoverflow.com/questions/31470730/comparing-tree-nodes
|
|
379
|
-
*/
|
|
380
|
-
// sort = (object1: INode, object2: INode): number => {
|
|
381
|
-
// if (!object1.parentNode) {
|
|
382
|
-
// return -1;
|
|
383
|
-
// }
|
|
384
|
-
// if (!object2.parentNode) {
|
|
385
|
-
// return 1;
|
|
386
|
-
// }
|
|
387
|
-
// const hierarchyDiff =
|
|
388
|
-
// (object1 as Element).transformable.graphDepth - (object2 as Element).transformable.graphDepth;
|
|
389
|
-
// let o1 = object1;
|
|
390
|
-
// let o2 = object2;
|
|
391
|
-
// if (hierarchyDiff < 0) {
|
|
392
|
-
// o2 = object2.getAncestor(-hierarchyDiff)!;
|
|
393
|
-
// if (o2 === o1) {
|
|
394
|
-
// return -1;
|
|
395
|
-
// }
|
|
396
|
-
// } else if (hierarchyDiff > 0) {
|
|
397
|
-
// o1 = object1.getAncestor(hierarchyDiff)!;
|
|
398
|
-
// if (o2 === o1) {
|
|
399
|
-
// return 1;
|
|
400
|
-
// }
|
|
401
|
-
// }
|
|
402
|
-
// while (o1 && o2 && o1.parentNode !== o2.parentNode) {
|
|
403
|
-
// o1 = o1.parentNode!;
|
|
404
|
-
// o2 = o2.parentNode!;
|
|
405
|
-
// }
|
|
406
|
-
// const parent = o1.parentNode;
|
|
407
|
-
// if (parent) {
|
|
408
|
-
// const parentSortable = (parent as Element).sortable;
|
|
409
|
-
// if (parentSortable) {
|
|
410
|
-
// // no need to re-sort, use cached sorted children
|
|
411
|
-
// if (!parentSortable.sorted) {
|
|
412
|
-
// parentSortable.sorted = (parent.childNodes as IElement[]).slice();
|
|
413
|
-
// }
|
|
414
|
-
// if (parentSortable.dirty) {
|
|
415
|
-
// parentSortable.sorted = (parent.childNodes as IElement[]).slice().sort(sortByZIndex);
|
|
416
|
-
// // parentSortable.sorted.forEach(
|
|
417
|
-
// // (child, i) => ((child as Element).sortable.lastSortedIndex = i),
|
|
418
|
-
// // );
|
|
419
|
-
// parentSortable.dirty = false;
|
|
420
|
-
// }
|
|
421
|
-
// // return (o1 as Element).sortable.lastSortedIndex - (o2 as Element).sortable.lastSortedIndex;
|
|
422
|
-
// return parentSortable.sorted.indexOf(o1) - parentSortable.sorted.indexOf(o2);
|
|
423
|
-
// }
|
|
424
|
-
// }
|
|
425
|
-
// return -1;
|
|
426
|
-
// };
|
|
427
|
-
|
|
428
373
|
|
|
429
374
|
DefaultSceneGraphService.prototype.getOrigin = function (element) {
|
|
430
375
|
return element.transformable.origin;
|
|
@@ -784,13 +729,14 @@ function () {
|
|
|
784
729
|
renderable.boundsDirty = true;
|
|
785
730
|
renderable.dirty = true;
|
|
786
731
|
} // model matrix changed
|
|
732
|
+
// element.emit(ElementEvent.ATTR_MODIFIED, {
|
|
733
|
+
// attributeName: 'modelMatrix',
|
|
734
|
+
// oldValue: null,
|
|
735
|
+
// newValue: null,
|
|
736
|
+
// });
|
|
787
737
|
|
|
788
738
|
|
|
789
|
-
element.
|
|
790
|
-
attributeName: 'modelMatrix',
|
|
791
|
-
oldValue: null,
|
|
792
|
-
newValue: null
|
|
793
|
-
});
|
|
739
|
+
element.dispatchEvent(new MutationEvent(ElementEvent.ATTR_MODIFIED, element, null, null, 'modelMatrix', MutationEvent.MODIFICATION, null, null));
|
|
794
740
|
}
|
|
795
741
|
};
|
|
796
742
|
|
|
@@ -836,22 +782,6 @@ function () {
|
|
|
836
782
|
}
|
|
837
783
|
};
|
|
838
784
|
|
|
839
|
-
DefaultSceneGraphService.prototype.updateGraphDepth = function (element) {
|
|
840
|
-
var transform = element.transformable;
|
|
841
|
-
|
|
842
|
-
if (element.parentNode) {
|
|
843
|
-
transform.graphDepth = element.parentNode.transformable.graphDepth + 1;
|
|
844
|
-
} else {
|
|
845
|
-
transform.graphDepth = 0;
|
|
846
|
-
}
|
|
847
|
-
|
|
848
|
-
var children = element.childNodes;
|
|
849
|
-
|
|
850
|
-
for (var i = 0; i < children.length; i++) {
|
|
851
|
-
this.updateGraphDepth(children[i]);
|
|
852
|
-
}
|
|
853
|
-
};
|
|
854
|
-
|
|
855
785
|
DefaultSceneGraphService.prototype.unfreezeParentToRoot = function (child) {
|
|
856
786
|
var p = child.parentNode;
|
|
857
787
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { singleton } from 'mana-syringe';
|
|
3
3
|
import { GeometryAABBUpdater } from './interfaces';
|
|
4
|
-
import {
|
|
4
|
+
import { Shape } from '../../types';
|
|
5
5
|
|
|
6
6
|
var CircleUpdater =
|
|
7
7
|
/** @class */
|
|
@@ -17,7 +17,7 @@ function () {
|
|
|
17
17
|
var unit = r.unit,
|
|
18
18
|
value = r.value;
|
|
19
19
|
var width = 0;
|
|
20
|
-
var height = 0;
|
|
20
|
+
var height = 0; // absolute unit
|
|
21
21
|
|
|
22
22
|
if (unit === '' || unit === 'px') {
|
|
23
23
|
width = value * 2;
|
|
@@ -36,7 +36,7 @@ function () {
|
|
|
36
36
|
CircleUpdater = __decorate([singleton({
|
|
37
37
|
token: {
|
|
38
38
|
token: GeometryAABBUpdater,
|
|
39
|
-
named:
|
|
39
|
+
named: Shape.CIRCLE
|
|
40
40
|
}
|
|
41
41
|
})], CircleUpdater);
|
|
42
42
|
return CircleUpdater;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { singleton } from 'mana-syringe';
|
|
3
3
|
import { GeometryAABBUpdater } from './interfaces';
|
|
4
|
-
import {
|
|
4
|
+
import { Shape } from '../../types';
|
|
5
5
|
|
|
6
6
|
var EllipseUpdater =
|
|
7
7
|
/** @class */
|
|
@@ -43,7 +43,7 @@ function () {
|
|
|
43
43
|
EllipseUpdater = __decorate([singleton({
|
|
44
44
|
token: {
|
|
45
45
|
token: GeometryAABBUpdater,
|
|
46
|
-
named:
|
|
46
|
+
named: Shape.ELLIPSE
|
|
47
47
|
}
|
|
48
48
|
})], EllipseUpdater);
|
|
49
49
|
return EllipseUpdater;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { singleton } from 'mana-syringe';
|
|
3
3
|
import { GeometryAABBUpdater } from './interfaces';
|
|
4
|
-
import {
|
|
4
|
+
import { Shape } from '../../types';
|
|
5
5
|
|
|
6
6
|
var LineUpdater =
|
|
7
7
|
/** @class */
|
|
@@ -30,7 +30,7 @@ function () {
|
|
|
30
30
|
LineUpdater = __decorate([singleton({
|
|
31
31
|
token: {
|
|
32
32
|
token: GeometryAABBUpdater,
|
|
33
|
-
named:
|
|
33
|
+
named: Shape.LINE
|
|
34
34
|
}
|
|
35
35
|
})], LineUpdater);
|
|
36
36
|
return LineUpdater;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { singleton } from 'mana-syringe';
|
|
3
3
|
import { GeometryAABBUpdater } from './interfaces';
|
|
4
|
-
import {
|
|
4
|
+
import { Shape } from '../../types';
|
|
5
5
|
|
|
6
6
|
var PathUpdater =
|
|
7
7
|
/** @class */
|
|
@@ -26,7 +26,7 @@ function () {
|
|
|
26
26
|
PathUpdater = __decorate([singleton({
|
|
27
27
|
token: {
|
|
28
28
|
token: GeometryAABBUpdater,
|
|
29
|
-
named:
|
|
29
|
+
named: Shape.PATH
|
|
30
30
|
}
|
|
31
31
|
})], PathUpdater);
|
|
32
32
|
return PathUpdater;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __decorate, __read, __spreadArray } from "tslib";
|
|
2
2
|
import { singleton } from 'mana-syringe';
|
|
3
3
|
import { GeometryAABBUpdater } from './interfaces';
|
|
4
|
-
import {
|
|
4
|
+
import { Shape } from '../../types';
|
|
5
5
|
|
|
6
6
|
var PolylineUpdater =
|
|
7
7
|
/** @class */
|
|
@@ -36,10 +36,10 @@ function () {
|
|
|
36
36
|
PolylineUpdater = __decorate([singleton({
|
|
37
37
|
token: [{
|
|
38
38
|
token: GeometryAABBUpdater,
|
|
39
|
-
named:
|
|
39
|
+
named: Shape.POLYLINE
|
|
40
40
|
}, {
|
|
41
41
|
token: GeometryAABBUpdater,
|
|
42
|
-
named:
|
|
42
|
+
named: Shape.POLYGON
|
|
43
43
|
}]
|
|
44
44
|
})], PolylineUpdater);
|
|
45
45
|
return PolylineUpdater;
|
|
@@ -2,7 +2,7 @@ import { __decorate } from "tslib";
|
|
|
2
2
|
import { singleton } from 'mana-syringe';
|
|
3
3
|
import { isString } from '@antv/util';
|
|
4
4
|
import { GeometryAABBUpdater } from './interfaces';
|
|
5
|
-
import {
|
|
5
|
+
import { Shape } from '../../types';
|
|
6
6
|
|
|
7
7
|
var RectUpdater =
|
|
8
8
|
/** @class */
|
|
@@ -56,13 +56,13 @@ function () {
|
|
|
56
56
|
RectUpdater = __decorate([singleton({
|
|
57
57
|
token: [{
|
|
58
58
|
token: GeometryAABBUpdater,
|
|
59
|
-
named:
|
|
59
|
+
named: Shape.RECT
|
|
60
60
|
}, {
|
|
61
61
|
token: GeometryAABBUpdater,
|
|
62
|
-
named:
|
|
62
|
+
named: Shape.IMAGE
|
|
63
63
|
}, {
|
|
64
64
|
token: GeometryAABBUpdater,
|
|
65
|
-
named:
|
|
65
|
+
named: Shape.GROUP
|
|
66
66
|
}]
|
|
67
67
|
})], RectUpdater);
|
|
68
68
|
return RectUpdater;
|
|
@@ -3,7 +3,7 @@ import { vec3 } from 'gl-matrix';
|
|
|
3
3
|
import { singleton, inject } from 'mana-syringe';
|
|
4
4
|
import { GeometryAABBUpdater } from './interfaces';
|
|
5
5
|
import { TextService } from '../text';
|
|
6
|
-
import {
|
|
6
|
+
import { Shape } from '../../types';
|
|
7
7
|
|
|
8
8
|
var TextUpdater =
|
|
9
9
|
/** @class */
|
|
@@ -14,15 +14,28 @@ function () {
|
|
|
14
14
|
var _a = parsedStyle.text,
|
|
15
15
|
text = _a === void 0 ? '' : _a,
|
|
16
16
|
textAlign = parsedStyle.textAlign,
|
|
17
|
-
|
|
18
|
-
lineWidth = _b === void 0 ? 0 : _b,
|
|
17
|
+
lineWidth = parsedStyle.lineWidth,
|
|
19
18
|
textBaseline = parsedStyle.textBaseline,
|
|
20
|
-
|
|
21
|
-
x =
|
|
22
|
-
|
|
23
|
-
y =
|
|
19
|
+
_b = parsedStyle.x,
|
|
20
|
+
x = _b === void 0 ? 0 : _b,
|
|
21
|
+
_c = parsedStyle.y,
|
|
22
|
+
y = _c === void 0 ? 0 : _c,
|
|
23
|
+
dx = parsedStyle.dx,
|
|
24
|
+
dy = parsedStyle.dy;
|
|
24
25
|
var metrics = this.textService.measureText(text, parsedStyle);
|
|
25
26
|
parsedStyle.metrics = metrics;
|
|
27
|
+
|
|
28
|
+
if (!text) {
|
|
29
|
+
return {
|
|
30
|
+
width: 0,
|
|
31
|
+
height: 0,
|
|
32
|
+
x: 0,
|
|
33
|
+
y: 0,
|
|
34
|
+
offsetX: 0,
|
|
35
|
+
offsetY: 0
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
26
39
|
var width = metrics.width,
|
|
27
40
|
height = metrics.height,
|
|
28
41
|
lineHeight = metrics.lineHeight,
|
|
@@ -34,10 +47,10 @@ function () {
|
|
|
34
47
|
var lineXOffset = 0;
|
|
35
48
|
|
|
36
49
|
if (textAlign === 'center') {
|
|
37
|
-
lineXOffset = lineWidth / 2;
|
|
50
|
+
lineXOffset = lineWidth.value / 2;
|
|
38
51
|
anchor = [0.5, 1];
|
|
39
52
|
} else if (textAlign === 'right' || textAlign === 'end') {
|
|
40
|
-
lineXOffset = lineWidth;
|
|
53
|
+
lineXOffset = lineWidth.value;
|
|
41
54
|
anchor = [1, 1];
|
|
42
55
|
} // update anchor
|
|
43
56
|
|
|
@@ -57,6 +70,14 @@ function () {
|
|
|
57
70
|
} // TODO: ideographic & bottom
|
|
58
71
|
|
|
59
72
|
|
|
73
|
+
if (dx && dx.unit === 'px') {
|
|
74
|
+
lineXOffset += dx.value;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (dy && dy.unit === 'px') {
|
|
78
|
+
lineYOffset += dy.value;
|
|
79
|
+
}
|
|
80
|
+
|
|
60
81
|
return {
|
|
61
82
|
width: halfExtents[0] * 2,
|
|
62
83
|
height: halfExtents[1] * 2,
|
|
@@ -72,7 +93,7 @@ function () {
|
|
|
72
93
|
TextUpdater = __decorate([singleton({
|
|
73
94
|
token: {
|
|
74
95
|
token: GeometryAABBUpdater,
|
|
75
|
-
named:
|
|
96
|
+
named: Shape.TEXT
|
|
76
97
|
}
|
|
77
98
|
})], TextUpdater);
|
|
78
99
|
return TextUpdater;
|