@antv/g 1.0.0-alpha.20 → 1.0.0-alpha.24
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/es/Canvas.d.ts +40 -18
- package/es/Canvas.js +121 -65
- package/es/DisplayObjectPool.d.ts +2 -1
- package/es/DisplayObjectPool.js +4 -0
- package/{lib → es/camera}/Camera.d.ts +6 -3
- package/es/{Camera.js → camera/Camera.js} +22 -16
- package/es/{Landmark.d.ts → camera/Landmark.d.ts} +2 -2
- package/es/{Landmark.js → camera/Landmark.js} +1 -1
- package/es/camera/index.d.ts +2 -0
- package/es/camera/index.js +2 -0
- package/es/components/Cullable.js +1 -1
- package/es/components/Geometry.d.ts +8 -1
- package/es/components/Renderable.d.ts +9 -8
- package/es/components/Renderable.js +2 -6
- package/es/components/Sortable.d.ts +6 -2
- package/es/display-objects/Circle.d.ts +2 -3
- package/es/display-objects/Circle.js +2 -5
- package/es/{CustomElement.d.ts → display-objects/CustomElement.d.ts} +1 -1
- package/es/{CustomElement.js → display-objects/CustomElement.js} +22 -12
- package/{lib → es/display-objects}/DisplayObject.d.ts +136 -141
- package/es/{DisplayObject.js → display-objects/DisplayObject.js} +408 -292
- package/es/display-objects/Ellipse.d.ts +2 -3
- package/es/display-objects/Ellipse.js +2 -5
- package/es/display-objects/Group.d.ts +2 -1
- package/es/display-objects/Group.js +13 -5
- package/es/display-objects/HTML.d.ts +2 -2
- package/es/display-objects/HTML.js +4 -7
- package/es/display-objects/Image.d.ts +2 -2
- package/es/display-objects/Image.js +2 -6
- package/es/display-objects/Line.d.ts +2 -2
- package/es/display-objects/Line.js +8 -8
- package/es/display-objects/Path.d.ts +3 -2
- package/es/display-objects/Path.js +8 -8
- package/es/display-objects/Polygon.d.ts +2 -2
- package/es/display-objects/Polygon.js +2 -6
- package/es/display-objects/Polyline.d.ts +2 -2
- package/es/display-objects/Polyline.js +8 -8
- package/es/display-objects/Rect.d.ts +2 -2
- package/es/display-objects/Rect.js +2 -6
- package/es/display-objects/Text.d.ts +2 -3
- package/es/display-objects/Text.js +8 -7
- package/es/display-objects/index.d.ts +2 -0
- package/es/display-objects/index.js +2 -0
- package/es/{Animation.d.ts → dom/Animation.d.ts} +3 -3
- package/es/{Animation.js → dom/Animation.js} +2 -3
- package/{lib → es/dom}/AnimationEffectTiming.d.ts +2 -0
- package/es/{AnimationEffectTiming.js → dom/AnimationEffectTiming.js} +3 -2
- package/es/{AnimationEvent.d.ts → dom/AnimationEvent.d.ts} +3 -2
- package/es/{AnimationEvent.js → dom/AnimationEvent.js} +1 -1
- package/es/{Timeline.d.ts → dom/AnimationTimeline.d.ts} +1 -1
- package/es/{Timeline.js → dom/AnimationTimeline.js} +1 -1
- package/es/dom/CustomElementRegistry.d.ts +15 -0
- package/es/dom/CustomElementRegistry.js +40 -0
- package/{lib → es/dom}/CustomEvent.d.ts +1 -1
- package/es/{CustomEvent.js → dom/CustomEvent.js} +1 -1
- package/es/dom/Document.d.ts +36 -17
- package/es/dom/Document.js +98 -14
- package/es/dom/Element.d.ts +71 -92
- package/es/dom/Element.js +179 -195
- package/es/dom/EventTarget.d.ts +11 -6
- package/es/dom/EventTarget.js +12 -4
- package/es/dom/FederatedEvent.d.ts +15 -7
- package/es/dom/FederatedEvent.js +33 -0
- package/es/dom/FederatedMouseEvent.d.ts +1 -1
- package/es/{KeyframeEffect.d.ts → dom/KeyframeEffect.d.ts} +16 -5
- package/es/{KeyframeEffect.js → dom/KeyframeEffect.js} +50 -4
- package/es/{KeyframeList.d.ts → dom/KeyframeList.d.ts} +1 -1
- package/es/{KeyframeList.js → dom/KeyframeList.js} +0 -0
- package/es/dom/Node.d.ts +38 -23
- package/es/dom/Node.js +37 -33
- package/es/dom/index.d.ts +15 -2
- package/es/dom/index.js +16 -3
- package/es/dom/interfaces.d.ts +301 -0
- package/es/dom/interfaces.js +1 -0
- package/es/global-module.d.ts +0 -2
- package/es/global-module.js +31 -29
- package/es/index.d.ts +7 -14
- package/es/index.js +8 -15
- package/es/plugins/CullingPlugin.d.ts +2 -2
- package/es/plugins/CullingPlugin.js +13 -16
- package/es/plugins/DirtyCheckPlugin.d.ts +1 -1
- package/es/plugins/DirtyCheckPlugin.js +8 -7
- package/es/plugins/EventPlugin.js +52 -31
- package/es/plugins/FrustumCullingStrategy.d.ts +1 -1
- package/es/plugins/FrustumCullingStrategy.js +5 -4
- package/es/plugins/PrepareRendererPlugin.d.ts +0 -1
- package/es/plugins/PrepareRendererPlugin.js +42 -38
- package/es/property-handlers/aabb.d.ts +2 -3
- package/es/property-handlers/aabb.js +29 -21
- package/es/property-handlers/anchor.d.ts +3 -0
- package/es/property-handlers/anchor.js +21 -0
- package/es/property-handlers/clipPath.d.ts +1 -1
- package/es/property-handlers/clipPath.js +3 -4
- package/es/property-handlers/color.d.ts +1 -1
- package/es/property-handlers/dimension.d.ts +1 -1
- package/es/property-handlers/dimension.js +6 -9
- package/es/property-handlers/filter.d.ts +1 -1
- package/es/property-handlers/index.d.ts +5 -4
- package/es/property-handlers/index.js +1 -0
- package/es/property-handlers/localPosition.d.ts +1 -1
- package/es/property-handlers/localPosition.js +1 -6
- package/es/property-handlers/offsetDistance.d.ts +1 -1
- package/es/property-handlers/offsetPath.d.ts +1 -1
- package/es/property-handlers/origin.d.ts +1 -1
- package/es/property-handlers/origin.js +9 -2
- package/es/property-handlers/path.d.ts +2 -2
- package/es/property-handlers/path.js +8 -4
- package/es/property-handlers/points.d.ts +1 -1
- package/es/property-handlers/transform.d.ts +1 -1
- package/es/property-handlers/zIndex.d.ts +1 -1
- package/es/services/ContextService.d.ts +3 -2
- package/es/services/EventService.d.ts +18 -13
- package/es/services/EventService.js +604 -384
- package/es/services/RenderingContext.d.ts +1 -1
- package/es/services/RenderingService.d.ts +23 -29
- package/es/services/RenderingService.js +63 -54
- package/es/services/SceneGraphSelector.d.ts +7 -7
- package/es/services/SceneGraphSelector.js +10 -6
- package/es/services/SceneGraphService.d.ts +73 -78
- package/es/services/SceneGraphService.js +165 -78
- package/es/services/aabb/PathUpdater.d.ts +1 -1
- package/es/services/aabb/RectUpdater.d.ts +2 -2
- package/es/services/aabb/interfaces.d.ts +1 -1
- package/es/shapes/Point.d.ts +4 -0
- package/es/shapes/Polygon.d.ts +9 -0
- package/es/shapes/Polygon.js +62 -0
- package/es/shapes/index.d.ts +1 -0
- package/es/shapes/index.js +2 -1
- package/es/types.d.ts +18 -6
- package/es/utils/animation.d.ts +1 -2
- package/es/utils/animation.js +5 -10
- package/es/utils/canvas.d.ts +1 -1
- package/es/utils/custom-easing.d.ts +3 -2
- package/es/utils/custom-easing.js +12 -6
- package/es/utils/event.js +1 -1
- package/es/utils/index.d.ts +1 -0
- package/es/utils/index.js +2 -1
- package/es/utils/interpolation.d.ts +3 -4
- package/es/utils/interpolation.js +0 -16
- package/es/utils/path.d.ts +2 -2
- package/lib/Canvas.d.ts +40 -18
- package/lib/Canvas.js +131 -74
- package/lib/DisplayObjectPool.d.ts +2 -1
- package/lib/DisplayObjectPool.js +4 -0
- package/{es → lib/camera}/Camera.d.ts +6 -3
- package/lib/{Camera.js → camera/Camera.js} +25 -20
- package/lib/{Landmark.d.ts → camera/Landmark.d.ts} +2 -2
- package/lib/{Landmark.js → camera/Landmark.js} +2 -3
- package/lib/camera/index.d.ts +2 -0
- package/lib/camera/index.js +31 -0
- package/lib/components/Cullable.js +1 -1
- package/lib/components/Geometry.d.ts +8 -1
- package/lib/components/Renderable.d.ts +9 -8
- package/lib/components/Renderable.js +2 -6
- package/lib/components/Sortable.d.ts +6 -2
- package/lib/display-objects/Circle.d.ts +2 -3
- package/lib/display-objects/Circle.js +3 -6
- package/lib/{CustomElement.d.ts → display-objects/CustomElement.d.ts} +1 -1
- package/lib/{CustomElement.js → display-objects/CustomElement.js} +22 -12
- package/{es → lib/display-objects}/DisplayObject.d.ts +136 -141
- package/lib/{DisplayObject.js → display-objects/DisplayObject.js} +418 -299
- package/lib/display-objects/Ellipse.d.ts +2 -3
- package/lib/display-objects/Ellipse.js +3 -6
- package/lib/display-objects/Group.d.ts +2 -1
- package/lib/display-objects/Group.js +12 -4
- package/lib/display-objects/HTML.d.ts +2 -2
- package/lib/display-objects/HTML.js +4 -7
- package/lib/display-objects/Image.d.ts +2 -2
- package/lib/display-objects/Image.js +2 -6
- package/lib/display-objects/Line.d.ts +2 -2
- package/lib/display-objects/Line.js +8 -8
- package/lib/display-objects/Path.d.ts +3 -2
- package/lib/display-objects/Path.js +8 -8
- package/lib/display-objects/Polygon.d.ts +2 -2
- package/lib/display-objects/Polygon.js +2 -6
- package/lib/display-objects/Polyline.d.ts +2 -2
- package/lib/display-objects/Polyline.js +8 -8
- package/lib/display-objects/Rect.d.ts +2 -2
- package/lib/display-objects/Rect.js +2 -6
- package/lib/display-objects/Text.d.ts +2 -3
- package/lib/display-objects/Text.js +9 -8
- package/lib/display-objects/index.d.ts +2 -0
- package/lib/display-objects/index.js +26 -0
- package/lib/{Animation.d.ts → dom/Animation.d.ts} +3 -3
- package/lib/{Animation.js → dom/Animation.js} +2 -3
- package/{es → lib/dom}/AnimationEffectTiming.d.ts +2 -0
- package/lib/{AnimationEffectTiming.js → dom/AnimationEffectTiming.js} +3 -3
- package/lib/{AnimationEvent.d.ts → dom/AnimationEvent.d.ts} +3 -2
- package/lib/{AnimationEvent.js → dom/AnimationEvent.js} +1 -1
- package/lib/{Timeline.d.ts → dom/AnimationTimeline.d.ts} +1 -1
- package/lib/{Timeline.js → dom/AnimationTimeline.js} +1 -1
- package/lib/dom/CustomElementRegistry.d.ts +15 -0
- package/lib/dom/CustomElementRegistry.js +48 -0
- package/{es → lib/dom}/CustomEvent.d.ts +1 -1
- package/lib/{CustomEvent.js → dom/CustomEvent.js} +1 -1
- package/lib/dom/Document.d.ts +36 -17
- package/lib/dom/Document.js +99 -15
- package/lib/dom/Element.d.ts +71 -92
- package/lib/dom/Element.js +180 -198
- package/lib/dom/EventTarget.d.ts +11 -6
- package/lib/dom/EventTarget.js +20 -10
- package/lib/dom/FederatedEvent.d.ts +15 -7
- package/lib/dom/FederatedEvent.js +33 -0
- package/lib/dom/FederatedMouseEvent.d.ts +1 -1
- package/lib/{KeyframeEffect.d.ts → dom/KeyframeEffect.d.ts} +16 -5
- package/lib/{KeyframeEffect.js → dom/KeyframeEffect.js} +50 -4
- package/lib/{KeyframeList.d.ts → dom/KeyframeList.d.ts} +1 -1
- package/lib/{KeyframeList.js → dom/KeyframeList.js} +0 -0
- package/lib/dom/Node.d.ts +38 -23
- package/lib/dom/Node.js +37 -33
- package/lib/dom/index.d.ts +15 -2
- package/lib/dom/index.js +177 -8
- package/lib/dom/interfaces.d.ts +301 -0
- package/lib/dom/interfaces.js +5 -0
- package/lib/global-module.d.ts +0 -2
- package/lib/global-module.js +30 -30
- package/lib/index.d.ts +7 -14
- package/lib/index.js +44 -135
- package/lib/plugins/CullingPlugin.d.ts +2 -2
- package/lib/plugins/CullingPlugin.js +14 -16
- package/lib/plugins/DirtyCheckPlugin.d.ts +1 -1
- package/lib/plugins/DirtyCheckPlugin.js +9 -7
- package/lib/plugins/EventPlugin.js +52 -30
- package/lib/plugins/FrustumCullingStrategy.d.ts +1 -1
- package/lib/plugins/FrustumCullingStrategy.js +5 -4
- package/lib/plugins/PrepareRendererPlugin.d.ts +0 -1
- package/lib/plugins/PrepareRendererPlugin.js +41 -37
- package/lib/property-handlers/aabb.d.ts +2 -3
- package/lib/property-handlers/aabb.js +28 -22
- package/lib/property-handlers/anchor.d.ts +3 -0
- package/lib/property-handlers/anchor.js +34 -0
- package/lib/property-handlers/clipPath.d.ts +1 -1
- package/lib/property-handlers/clipPath.js +3 -4
- package/lib/property-handlers/color.d.ts +1 -1
- package/lib/property-handlers/dimension.d.ts +1 -1
- package/lib/property-handlers/dimension.js +6 -9
- package/lib/property-handlers/filter.d.ts +1 -1
- package/lib/property-handlers/index.d.ts +5 -4
- package/lib/property-handlers/index.js +14 -0
- package/lib/property-handlers/localPosition.d.ts +1 -1
- package/lib/property-handlers/localPosition.js +1 -7
- package/lib/property-handlers/offsetDistance.d.ts +1 -1
- package/lib/property-handlers/offsetPath.d.ts +1 -1
- package/lib/property-handlers/origin.d.ts +1 -1
- package/lib/property-handlers/origin.js +10 -2
- package/lib/property-handlers/path.d.ts +2 -2
- package/lib/property-handlers/path.js +8 -4
- package/lib/property-handlers/points.d.ts +1 -1
- package/lib/property-handlers/transform.d.ts +1 -1
- package/lib/property-handlers/zIndex.d.ts +1 -1
- package/lib/services/ContextService.d.ts +3 -2
- package/lib/services/EventService.d.ts +18 -13
- package/lib/services/EventService.js +616 -385
- package/lib/services/RenderingContext.d.ts +1 -1
- package/lib/services/RenderingService.d.ts +23 -29
- package/lib/services/RenderingService.js +66 -56
- package/lib/services/SceneGraphSelector.d.ts +7 -7
- package/lib/services/SceneGraphSelector.js +10 -6
- package/lib/services/SceneGraphService.d.ts +73 -78
- package/lib/services/SceneGraphService.js +166 -79
- package/lib/services/aabb/PathUpdater.d.ts +1 -1
- package/lib/services/aabb/RectUpdater.d.ts +2 -2
- package/lib/services/aabb/interfaces.d.ts +1 -1
- package/lib/shapes/Point.d.ts +4 -0
- package/lib/shapes/Polygon.d.ts +9 -0
- package/lib/shapes/Polygon.js +69 -0
- package/lib/shapes/index.d.ts +1 -0
- package/lib/shapes/index.js +13 -0
- package/lib/types.d.ts +18 -6
- package/lib/utils/animation.d.ts +1 -2
- package/lib/utils/animation.js +8 -16
- package/lib/utils/canvas.d.ts +1 -1
- package/lib/utils/custom-easing.d.ts +3 -2
- package/lib/utils/custom-easing.js +16 -8
- package/lib/utils/event.js +1 -1
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +13 -0
- package/lib/utils/interpolation.d.ts +3 -4
- package/lib/utils/interpolation.js +0 -17
- package/lib/utils/path.d.ts +2 -2
- package/package.json +6 -6
- package/es/Batch.d.ts +0 -25
- package/es/Batch.js +0 -82
- package/es/shapes-type.d.ts +0 -175
- package/es/shapes-type.js +0 -18
- package/es/utils/matrix-decompose.d.ts +0 -3
- package/es/utils/matrix-decompose.js +0 -404
- package/lib/Batch.d.ts +0 -25
- package/lib/Batch.js +0 -91
- package/lib/shapes-type.d.ts +0 -175
- package/lib/shapes-type.js +0 -41
- package/lib/utils/matrix-decompose.d.ts +0 -3
- package/lib/utils/matrix-decompose.js +0 -414
|
@@ -11,23 +11,33 @@ var _util = require("@antv/util");
|
|
|
11
11
|
|
|
12
12
|
var _glMatrix = require("gl-matrix");
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _DisplayObjectPool = require("../DisplayObjectPool");
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _dom = require("../dom");
|
|
17
17
|
|
|
18
|
-
var
|
|
18
|
+
var _2 = require("..");
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _utils = require("../utils");
|
|
21
21
|
|
|
22
|
-
var
|
|
22
|
+
var _components = require("../components");
|
|
23
23
|
|
|
24
|
-
var _propertyHandlers = require("
|
|
24
|
+
var _propertyHandlers = require("../property-handlers");
|
|
25
25
|
|
|
26
|
-
var
|
|
26
|
+
var _services = require("../services");
|
|
27
27
|
|
|
28
|
+
var DEFAULT_STYLE_PROPS = {
|
|
29
|
+
anchor: [0, 0, 0],
|
|
30
|
+
origin: [0, 0, 0],
|
|
31
|
+
opacity: 1,
|
|
32
|
+
fillOpacity: 1,
|
|
33
|
+
strokeOpacity: 1
|
|
34
|
+
};
|
|
28
35
|
/**
|
|
29
36
|
* prototype chains: DisplayObject -> Element -> Node -> EventTarget
|
|
30
37
|
*
|
|
38
|
+
* mixins: Animatable, Transformable, Visible
|
|
39
|
+
* @see https://github.com/tannerntannern/ts-mixer/blob/master/README.md#mixing-generic-classes
|
|
40
|
+
*
|
|
31
41
|
* Provide abilities in scene graph, such as:
|
|
32
42
|
* * transform `translate/rotate/scale`
|
|
33
43
|
* * add/remove child
|
|
@@ -40,33 +50,25 @@ var _Element = require("./dom/Element");
|
|
|
40
50
|
* * destroy
|
|
41
51
|
* * attributeChanged
|
|
42
52
|
*/
|
|
53
|
+
|
|
43
54
|
var DisplayObject = function (_super) {
|
|
44
55
|
(0, _tslib.__extends)(DisplayObject, _super);
|
|
45
56
|
|
|
46
57
|
function DisplayObject(config) {
|
|
47
58
|
var _a, _b, _c;
|
|
48
59
|
|
|
49
|
-
var _this = _super.call(this) || this;
|
|
50
|
-
|
|
51
|
-
_this.shadow = false;
|
|
52
|
-
_this.displayObjectPool = _inversify.container.get(_DisplayObjectPool.DisplayObjectPool);
|
|
53
|
-
_this.stylePropertyUpdaterFactory = _inversify.container.get(_propertyHandlers.StylePropertyUpdaterFactory);
|
|
54
|
-
_this.stylePropertyParserFactory = _inversify.container.get(_propertyHandlers.StylePropertyParserFactory);
|
|
55
|
-
/** scene graph operations */
|
|
56
|
-
|
|
57
|
-
_this.scrollLeft = 0;
|
|
58
|
-
_this.scrollTop = 0;
|
|
60
|
+
var _this = _super.call(this, config) || this;
|
|
59
61
|
/**
|
|
60
|
-
*
|
|
62
|
+
* push to active animations after calling `animate()`
|
|
61
63
|
*/
|
|
62
64
|
|
|
63
|
-
_this.dataset = {}; // assign name, id to config
|
|
64
|
-
// eg. group.get('name')
|
|
65
|
-
|
|
66
|
-
_this.config = config; // insert this group into pool
|
|
67
65
|
|
|
68
|
-
_this.
|
|
66
|
+
_this.activeAnimations = [];
|
|
67
|
+
_this.stylePropertyUpdaterFactory = _2.container.get(_propertyHandlers.StylePropertyUpdaterFactory);
|
|
68
|
+
_this.stylePropertyParserFactory = _2.container.get(_propertyHandlers.StylePropertyParserFactory); // assign name, id to config
|
|
69
|
+
// eg. group.get('name')
|
|
69
70
|
|
|
71
|
+
_this.config = config; // compatible with G 3.0
|
|
70
72
|
|
|
71
73
|
_this.config.interactive = (_a = _this.config.capture) !== null && _a !== void 0 ? _a : _this.config.interactive; // init scene graph node
|
|
72
74
|
|
|
@@ -74,14 +76,12 @@ var DisplayObject = function (_super) {
|
|
|
74
76
|
_this.name = _this.config.name || '';
|
|
75
77
|
_this.className = _this.config.className || '';
|
|
76
78
|
_this.interactive = (_b = _this.config.interactive) !== null && _b !== void 0 ? _b : true;
|
|
77
|
-
_this.nodeName = _this.config.type ||
|
|
78
|
-
_this.attributes; // compatible with G 3.0
|
|
79
|
-
// @ts-ignore
|
|
79
|
+
_this.nodeName = _this.config.type || _2.SHAPE.Group; // compatible with G 3.0
|
|
80
80
|
|
|
81
|
-
_this.config.style = (0, _tslib.__assign)((0, _tslib.__assign)({
|
|
81
|
+
_this.config.style = (0, _tslib.__assign)((0, _tslib.__assign)((0, _tslib.__assign)((0, _tslib.__assign)({}, DEFAULT_STYLE_PROPS), {
|
|
82
82
|
zIndex: (_c = _this.config.zIndex) !== null && _c !== void 0 ? _c : 0,
|
|
83
83
|
visibility: _this.config.visible === false ? 'hidden' : 'visible'
|
|
84
|
-
}, _this.config.style), _this.config.attrs);
|
|
84
|
+
}), _this.config.style), _this.config.attrs);
|
|
85
85
|
_this.style = new Proxy(_this.attributes, {
|
|
86
86
|
get: function get(_, prop) {
|
|
87
87
|
return _this.getAttribute(prop);
|
|
@@ -93,179 +93,172 @@ var DisplayObject = function (_super) {
|
|
|
93
93
|
}
|
|
94
94
|
});
|
|
95
95
|
|
|
96
|
-
_this.initAttributes(_this.config.style);
|
|
96
|
+
_this.initAttributes(_this.config.style); // insert this group into pool
|
|
97
97
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
if (_this.ownerDocument && _this.ownerDocument.documentElement === _this && _this.ownerDocument.defaultView) {
|
|
101
|
-
_this.ownerDocument.defaultView.decorate(child, _this.ownerDocument.defaultView.getRenderingService(), _this);
|
|
102
|
-
}
|
|
103
|
-
});
|
|
98
|
+
|
|
99
|
+
_2.container.get(_DisplayObjectPool.DisplayObjectPool).add(_this.entity.getName(), _this);
|
|
104
100
|
|
|
105
101
|
return _this;
|
|
106
102
|
}
|
|
107
|
-
/**
|
|
108
|
-
* compatible with G 3.0
|
|
109
|
-
* @deprecated
|
|
110
|
-
*/
|
|
111
103
|
|
|
104
|
+
DisplayObject.prototype.destroy = function () {
|
|
105
|
+
_super.prototype.destroy.call(this); // remove from into pool
|
|
112
106
|
|
|
113
|
-
DisplayObject.prototype.set = function (name, value) {
|
|
114
|
-
this.config[name] = value;
|
|
115
|
-
};
|
|
116
107
|
|
|
117
|
-
|
|
118
|
-
return this.config[name];
|
|
119
|
-
};
|
|
108
|
+
_2.container.get(_DisplayObjectPool.DisplayObjectPool).remove(this.entity.getName()); // stop all active animations
|
|
120
109
|
|
|
121
|
-
DisplayObject.prototype.getConfig = function () {
|
|
122
|
-
return this.config;
|
|
123
|
-
};
|
|
124
110
|
|
|
125
|
-
|
|
126
|
-
|
|
111
|
+
this.getAnimations().forEach(function (animation) {
|
|
112
|
+
animation.cancel();
|
|
113
|
+
});
|
|
114
|
+
};
|
|
127
115
|
|
|
128
|
-
|
|
116
|
+
DisplayObject.prototype.cloneNode = function (deep) {
|
|
117
|
+
var cloned = new this.constructor({
|
|
118
|
+
// copy id & name
|
|
119
|
+
// @see https://developer.mozilla.org/en-US/docs/Web/API/Node/cloneNode#notes
|
|
120
|
+
id: this.id,
|
|
121
|
+
name: this.name,
|
|
122
|
+
className: this.name,
|
|
123
|
+
interactive: this.interactive,
|
|
124
|
+
style: (0, _tslib.__assign)({}, this.style)
|
|
125
|
+
});
|
|
129
126
|
|
|
130
|
-
|
|
131
|
-
|
|
127
|
+
if (deep) {
|
|
128
|
+
this.children.forEach(function (child) {
|
|
129
|
+
var clonedChild = child.cloneNode(deep);
|
|
130
|
+
cloned.appendChild(clonedChild);
|
|
131
|
+
});
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
value = _a[1];
|
|
134
|
+
return cloned;
|
|
135
|
+
};
|
|
137
136
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}
|
|
137
|
+
DisplayObject.prototype.initAttributes = function (attributes) {
|
|
138
|
+
var _this = this;
|
|
141
139
|
|
|
142
|
-
if (
|
|
143
|
-
|
|
144
|
-
_this.setAttribute(key, name[key]);
|
|
145
|
-
});
|
|
146
|
-
return this;
|
|
140
|
+
if (attributes === void 0) {
|
|
141
|
+
attributes = {};
|
|
147
142
|
}
|
|
148
143
|
|
|
149
|
-
|
|
150
|
-
this.setAttribute(name, value);
|
|
151
|
-
return this;
|
|
152
|
-
}
|
|
144
|
+
var renderable = this.entity.getComponent(_components.Renderable); // parse attributes first
|
|
153
145
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
* @deprecated
|
|
158
|
-
* compatible with G 3.0
|
|
159
|
-
* @deprecated
|
|
160
|
-
*/
|
|
146
|
+
for (var attributeName in attributes) {
|
|
147
|
+
var value = attributes[attributeName];
|
|
148
|
+
this.attributes[attributeName] = value; // @ts-ignore
|
|
161
149
|
|
|
150
|
+
this.parseStyleProperty(attributeName, value);
|
|
151
|
+
}
|
|
162
152
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
* @deprecated
|
|
168
|
-
* compatible with G 3.0
|
|
169
|
-
* @deprecated
|
|
170
|
-
*/
|
|
153
|
+
var priorities = {
|
|
154
|
+
x: 1000,
|
|
155
|
+
y: 1000
|
|
156
|
+
}; // update x, y at last
|
|
171
157
|
|
|
158
|
+
var sortedNames = Object.keys(attributes).sort(function (a, b) {
|
|
159
|
+
return (priorities[a] || 0) - (priorities[b] || 0);
|
|
160
|
+
});
|
|
161
|
+
sortedNames.forEach(function (attributeName) {
|
|
162
|
+
// @ts-ignore
|
|
163
|
+
_this.updateStyleProperty(attributeName, undefined, _this.parsedStyle[attributeName]);
|
|
164
|
+
}); // redraw at next frame
|
|
172
165
|
|
|
173
|
-
|
|
174
|
-
return this.parentNode;
|
|
166
|
+
renderable.dirty = true;
|
|
175
167
|
};
|
|
176
|
-
/**
|
|
177
|
-
* @deprecated
|
|
178
|
-
* compatible with G 3.0
|
|
179
|
-
* @deprecated
|
|
180
|
-
*/
|
|
181
168
|
|
|
169
|
+
DisplayObject.prototype.setAttribute = function (attributeName, value, force) {
|
|
170
|
+
if (force === void 0) {
|
|
171
|
+
force = false;
|
|
172
|
+
}
|
|
182
173
|
|
|
183
|
-
|
|
184
|
-
|
|
174
|
+
if (force || !(0, _util.isEqual)(value, this.attributes[attributeName]) || attributeName === 'transformOrigin' || attributeName === 'visibility' // will affect children
|
|
175
|
+
) {
|
|
176
|
+
if (attributeName === 'visibility') {
|
|
177
|
+
// set value cascade
|
|
178
|
+
this.forEach(function (object) {
|
|
179
|
+
object.changeAttribute(attributeName, value);
|
|
180
|
+
});
|
|
181
|
+
} else {
|
|
182
|
+
this.changeAttribute(attributeName, value);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
_super.prototype.setAttribute.call(this, attributeName, value);
|
|
186
|
+
}
|
|
185
187
|
};
|
|
186
188
|
/**
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
*
|
|
189
|
+
* parse property, eg.
|
|
190
|
+
* * fill: 'red' => [1, 0, 0, 1]
|
|
191
|
+
* * translateX: '10px' => { unit: 'px', value: 10 }
|
|
190
192
|
*/
|
|
191
193
|
|
|
192
194
|
|
|
193
|
-
DisplayObject.prototype.
|
|
194
|
-
|
|
195
|
+
DisplayObject.prototype.parseStyleProperty = function (name, value) {
|
|
196
|
+
var stylePropertyParser = this.stylePropertyParserFactory(name);
|
|
197
|
+
|
|
198
|
+
if (stylePropertyParser) {
|
|
199
|
+
// @ts-ignore
|
|
200
|
+
this.parsedStyle[name] = stylePropertyParser(value, this);
|
|
201
|
+
} else {
|
|
202
|
+
this.parsedStyle[name] = value;
|
|
203
|
+
}
|
|
195
204
|
};
|
|
196
|
-
/**
|
|
197
|
-
* @deprecated
|
|
198
|
-
* compatible with G 3.0
|
|
199
|
-
* @deprecated
|
|
200
|
-
* get last child group/shape
|
|
201
|
-
*/
|
|
202
205
|
|
|
206
|
+
DisplayObject.prototype.updateStyleProperty = function (name, oldParsedValue, newParsedValue) {
|
|
207
|
+
var _this = this; // update property, which may cause AABB re-calc
|
|
208
|
+
// @ts-ignore
|
|
203
209
|
|
|
204
|
-
DisplayObject.prototype.getLast = function () {
|
|
205
|
-
return this.lastChild;
|
|
206
|
-
};
|
|
207
|
-
/**
|
|
208
|
-
* @deprecated
|
|
209
|
-
* compatible with G 3.0
|
|
210
|
-
* @deprecated
|
|
211
|
-
* get child group/shape by index
|
|
212
|
-
*/
|
|
213
210
|
|
|
211
|
+
var stylePropertyUpdaters = this.stylePropertyUpdaterFactory(name);
|
|
214
212
|
|
|
215
|
-
|
|
216
|
-
|
|
213
|
+
if (stylePropertyUpdaters) {
|
|
214
|
+
stylePropertyUpdaters.forEach(function (updater) {
|
|
215
|
+
// @ts-ignore
|
|
216
|
+
updater(oldParsedValue, newParsedValue, _this, _this.sceneGraphService);
|
|
217
|
+
});
|
|
218
|
+
}
|
|
217
219
|
};
|
|
218
220
|
/**
|
|
219
|
-
*
|
|
220
|
-
* @deprecated
|
|
221
|
+
* called when attributes get changed or initialized
|
|
221
222
|
*/
|
|
222
223
|
|
|
223
224
|
|
|
224
|
-
DisplayObject.prototype.
|
|
225
|
-
this
|
|
226
|
-
};
|
|
227
|
-
/** transform operations */
|
|
228
|
-
|
|
225
|
+
DisplayObject.prototype.changeAttribute = function (name, value) {
|
|
226
|
+
var _this = this;
|
|
229
227
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
}
|
|
228
|
+
var entity = this.getEntity();
|
|
229
|
+
var renderable = entity.getComponent(_components.Renderable);
|
|
230
|
+
var oldValue = this.attributes[name]; // @ts-ignore
|
|
234
231
|
|
|
235
|
-
|
|
236
|
-
z = 0;
|
|
237
|
-
}
|
|
232
|
+
var oldParsedValue = this.parsedStyle[name]; // update value
|
|
238
233
|
|
|
239
|
-
this.
|
|
240
|
-
return this;
|
|
241
|
-
};
|
|
234
|
+
this.attributes[name] = value; // @ts-ignore
|
|
242
235
|
|
|
243
|
-
|
|
244
|
-
return this.sceneGraphService.getOrigin(this);
|
|
245
|
-
};
|
|
246
|
-
/**
|
|
247
|
-
* alias setPosition
|
|
248
|
-
*/
|
|
236
|
+
this.parseStyleProperty(name, value); // @ts-ignore
|
|
249
237
|
|
|
238
|
+
this.updateStyleProperty(name, oldParsedValue, this.parsedStyle[name]); // inform clip path targets
|
|
250
239
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
240
|
+
if (this.attributes.clipPathTargets && this.attributes.clipPathTargets.length) {
|
|
241
|
+
this.attributes.clipPathTargets.forEach(function (target) {
|
|
242
|
+
(0, _services.dirtifyRenderable)(target);
|
|
243
|
+
target.emit(_dom.ElementEvent.ATTRIBUTE_CHANGED, {
|
|
244
|
+
attributeName: 'clipPath',
|
|
245
|
+
oldValue: _this,
|
|
246
|
+
newValue: _this
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
} // redraw at next frame
|
|
255
250
|
|
|
256
|
-
if (z === void 0) {
|
|
257
|
-
z = 0;
|
|
258
|
-
}
|
|
259
251
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
252
|
+
renderable.dirty = true;
|
|
253
|
+
this.emit(_dom.ElementEvent.ATTRIBUTE_CHANGED, {
|
|
254
|
+
attributeName: name,
|
|
255
|
+
oldValue: oldValue,
|
|
256
|
+
newValue: value
|
|
257
|
+
});
|
|
258
|
+
}; // #region transformable
|
|
266
259
|
|
|
267
260
|
|
|
268
|
-
DisplayObject.prototype.
|
|
261
|
+
DisplayObject.prototype.setOrigin = function (position, y, z) {
|
|
269
262
|
if (y === void 0) {
|
|
270
263
|
y = 0;
|
|
271
264
|
}
|
|
@@ -274,12 +267,15 @@ var DisplayObject = function (_super) {
|
|
|
274
267
|
z = 0;
|
|
275
268
|
}
|
|
276
269
|
|
|
277
|
-
this.
|
|
270
|
+
this.sceneGraphService.setOrigin(this, (0, _utils.createVec3)(position, y, z));
|
|
271
|
+
this.attributes.origin = this.getOrigin();
|
|
278
272
|
return this;
|
|
279
273
|
};
|
|
274
|
+
|
|
275
|
+
DisplayObject.prototype.getOrigin = function () {
|
|
276
|
+
return this.sceneGraphService.getOrigin(this);
|
|
277
|
+
};
|
|
280
278
|
/**
|
|
281
|
-
* compatible with G 3.0
|
|
282
|
-
*
|
|
283
279
|
* set position in world space
|
|
284
280
|
*/
|
|
285
281
|
|
|
@@ -293,7 +289,7 @@ var DisplayObject = function (_super) {
|
|
|
293
289
|
z = 0;
|
|
294
290
|
}
|
|
295
291
|
|
|
296
|
-
this.sceneGraphService.setPosition(this, (0,
|
|
292
|
+
this.sceneGraphService.setPosition(this, (0, _utils.createVec3)(position, y, z));
|
|
297
293
|
this.syncLocalPosition();
|
|
298
294
|
return this;
|
|
299
295
|
};
|
|
@@ -311,7 +307,7 @@ var DisplayObject = function (_super) {
|
|
|
311
307
|
z = 0;
|
|
312
308
|
}
|
|
313
309
|
|
|
314
|
-
this.sceneGraphService.setLocalPosition(this, (0,
|
|
310
|
+
this.sceneGraphService.setLocalPosition(this, (0, _utils.createVec3)(position, y, z));
|
|
315
311
|
this.syncLocalPosition();
|
|
316
312
|
return this;
|
|
317
313
|
};
|
|
@@ -329,7 +325,7 @@ var DisplayObject = function (_super) {
|
|
|
329
325
|
z = 0;
|
|
330
326
|
}
|
|
331
327
|
|
|
332
|
-
this.sceneGraphService.translate(this, (0,
|
|
328
|
+
this.sceneGraphService.translate(this, (0, _utils.createVec3)(position, y, z));
|
|
333
329
|
this.syncLocalPosition();
|
|
334
330
|
return this;
|
|
335
331
|
};
|
|
@@ -347,7 +343,7 @@ var DisplayObject = function (_super) {
|
|
|
347
343
|
z = 0;
|
|
348
344
|
}
|
|
349
345
|
|
|
350
|
-
this.sceneGraphService.translateLocal(this, (0,
|
|
346
|
+
this.sceneGraphService.translateLocal(this, (0, _utils.createVec3)(position, y, z));
|
|
351
347
|
this.syncLocalPosition();
|
|
352
348
|
return this;
|
|
353
349
|
};
|
|
@@ -377,7 +373,7 @@ var DisplayObject = function (_super) {
|
|
|
377
373
|
if (typeof scaling === 'number') {
|
|
378
374
|
y = y || scaling;
|
|
379
375
|
z = z || scaling;
|
|
380
|
-
scaling = (0,
|
|
376
|
+
scaling = (0, _utils.createVec3)(scaling, y, z);
|
|
381
377
|
}
|
|
382
378
|
|
|
383
379
|
this.sceneGraphService.scaleLocal(this, scaling);
|
|
@@ -392,7 +388,7 @@ var DisplayObject = function (_super) {
|
|
|
392
388
|
if (typeof scaling === 'number') {
|
|
393
389
|
y = y || scaling;
|
|
394
390
|
z = z || scaling;
|
|
395
|
-
scaling = (0,
|
|
391
|
+
scaling = (0, _utils.createVec3)(scaling, y, z);
|
|
396
392
|
}
|
|
397
393
|
|
|
398
394
|
this.sceneGraphService.setLocalScale(this, scaling);
|
|
@@ -420,14 +416,13 @@ var DisplayObject = function (_super) {
|
|
|
420
416
|
|
|
421
417
|
|
|
422
418
|
DisplayObject.prototype.getEulerAngles = function () {
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
var _a = (0, _tslib.__read)((0, _math.getEuler)(_glMatrix.vec3.create(), this.sceneGraphService.getWorldTransform(this, transform)), 3),
|
|
419
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
420
|
+
var _a = (0, _tslib.__read)((0, _utils.getEuler)(_glMatrix.vec3.create(), this.sceneGraphService.getWorldTransform(this)), 3),
|
|
426
421
|
ex = _a[0],
|
|
427
422
|
ey = _a[1],
|
|
428
423
|
ez = _a[2];
|
|
429
424
|
|
|
430
|
-
return (0,
|
|
425
|
+
return (0, _utils.rad2deg)(ez);
|
|
431
426
|
};
|
|
432
427
|
/**
|
|
433
428
|
* only return degrees of Z axis in local space
|
|
@@ -436,12 +431,12 @@ var DisplayObject = function (_super) {
|
|
|
436
431
|
|
|
437
432
|
DisplayObject.prototype.getLocalEulerAngles = function () {
|
|
438
433
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
439
|
-
var _a = (0, _tslib.__read)((0,
|
|
434
|
+
var _a = (0, _tslib.__read)((0, _utils.getEuler)(_glMatrix.vec3.create(), this.sceneGraphService.getLocalRotation(this)), 3),
|
|
440
435
|
ex = _a[0],
|
|
441
436
|
ey = _a[1],
|
|
442
437
|
ez = _a[2];
|
|
443
438
|
|
|
444
|
-
return (0,
|
|
439
|
+
return (0, _utils.rad2deg)(ez);
|
|
445
440
|
};
|
|
446
441
|
/**
|
|
447
442
|
* set euler angles(degrees) in world space
|
|
@@ -497,80 +492,83 @@ var DisplayObject = function (_super) {
|
|
|
497
492
|
DisplayObject.prototype.getWorldTransform = function () {
|
|
498
493
|
return this.sceneGraphService.getWorldTransform(this);
|
|
499
494
|
};
|
|
495
|
+
|
|
496
|
+
DisplayObject.prototype.resetLocalTransform = function () {
|
|
497
|
+
this.sceneGraphService.resetLocalTransform(this);
|
|
498
|
+
};
|
|
500
499
|
/**
|
|
501
|
-
*
|
|
502
|
-
*
|
|
500
|
+
* sync style.x/y when local position changed
|
|
501
|
+
*
|
|
502
|
+
* Mixins may not declare private/protected properties
|
|
503
|
+
* however, you can use ES2020 private fields
|
|
503
504
|
*/
|
|
504
505
|
|
|
505
506
|
|
|
506
|
-
DisplayObject.prototype.
|
|
507
|
-
var
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
var _b = (0, _tslib.__read)(_glMatrix.mat4.getScaling(_glMatrix.vec3.create(), transform), 2),
|
|
514
|
-
sx = _b[0],
|
|
515
|
-
sy = _b[1];
|
|
516
|
-
|
|
517
|
-
var rotation = _glMatrix.mat4.getRotation(_glMatrix.quat.create(), transform);
|
|
507
|
+
DisplayObject.prototype.syncLocalPosition = function () {
|
|
508
|
+
var localPosition = this.getLocalPosition();
|
|
509
|
+
this.attributes.x = localPosition[0];
|
|
510
|
+
this.attributes.y = localPosition[1];
|
|
511
|
+
}; // #endregion transformable
|
|
512
|
+
// #region animatable
|
|
518
513
|
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
514
|
+
/**
|
|
515
|
+
* returns an array of all Animation objects affecting this element
|
|
516
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getAnimations
|
|
517
|
+
*/
|
|
523
518
|
|
|
524
519
|
|
|
525
|
-
|
|
520
|
+
DisplayObject.prototype.getAnimations = function () {
|
|
521
|
+
return this.activeAnimations;
|
|
526
522
|
};
|
|
527
523
|
/**
|
|
528
|
-
*
|
|
529
|
-
* @
|
|
524
|
+
* create an animation with WAAPI
|
|
525
|
+
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/animate
|
|
530
526
|
*/
|
|
531
527
|
|
|
532
528
|
|
|
533
|
-
DisplayObject.prototype.
|
|
534
|
-
var
|
|
535
|
-
var row0y = mat[3];
|
|
536
|
-
var row1x = mat[1];
|
|
537
|
-
var row1y = mat[4]; // decompose 3x3 matrix
|
|
538
|
-
// @see https://www.w3.org/TR/css-transforms-1/#decomposing-a-2d-matrix
|
|
529
|
+
DisplayObject.prototype.animate = function (keyframes, options) {
|
|
530
|
+
var _a, _b;
|
|
539
531
|
|
|
540
|
-
var
|
|
541
|
-
var scalingY = Math.sqrt(row1x * row1x + row1y * row1y); // If determinant is negative, one axis was flipped.
|
|
532
|
+
var timeline = (_a = this.ownerDocument) === null || _a === void 0 ? void 0 : _a.timeline; // accounte for clip path, use target's timeline
|
|
542
533
|
|
|
543
|
-
|
|
534
|
+
if (this.attributes.clipPathTargets && this.attributes.clipPathTargets.length) {
|
|
535
|
+
var target = this.attributes.clipPathTargets[0];
|
|
536
|
+
timeline = (_b = target.ownerDocument) === null || _b === void 0 ? void 0 : _b.timeline;
|
|
537
|
+
} // clear old parsed transform
|
|
544
538
|
|
|
545
|
-
if (determinant < 0) {
|
|
546
|
-
// Flip axis with minimum unit vector dot product.
|
|
547
|
-
if (row0x < row1y) {
|
|
548
|
-
scalingX = -scalingX;
|
|
549
|
-
} else {
|
|
550
|
-
scalingY = -scalingY;
|
|
551
|
-
}
|
|
552
|
-
} // Renormalize matrix to remove scale.
|
|
553
539
|
|
|
540
|
+
this.parsedStyle.transform = undefined;
|
|
554
541
|
|
|
555
|
-
if (
|
|
556
|
-
|
|
557
|
-
row0y *= 1 / scalingX;
|
|
542
|
+
if (timeline) {
|
|
543
|
+
return timeline.play(new _dom.KeyframeEffect(this, keyframes, options));
|
|
558
544
|
}
|
|
559
545
|
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
} // Compute rotation and renormalize matrix.
|
|
546
|
+
return null;
|
|
547
|
+
}; // #endregion animatable
|
|
548
|
+
// #region visible
|
|
564
549
|
|
|
550
|
+
/**
|
|
551
|
+
* show group, which will also change visibility of its children in sceneGraphNode
|
|
552
|
+
*
|
|
553
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/visibility
|
|
554
|
+
*/
|
|
565
555
|
|
|
566
|
-
|
|
567
|
-
|
|
556
|
+
|
|
557
|
+
DisplayObject.prototype.show = function () {
|
|
558
|
+
this.style.visibility = 'visible';
|
|
568
559
|
};
|
|
569
|
-
|
|
560
|
+
/**
|
|
561
|
+
* hide group, which will also change visibility of its children in sceneGraphNode
|
|
562
|
+
*/
|
|
570
563
|
|
|
571
564
|
|
|
572
|
-
DisplayObject.prototype.
|
|
573
|
-
this.style.
|
|
565
|
+
DisplayObject.prototype.hide = function () {
|
|
566
|
+
this.style.visibility = 'hidden';
|
|
567
|
+
};
|
|
568
|
+
|
|
569
|
+
DisplayObject.prototype.isVisible = function () {
|
|
570
|
+
var cullable = this.entity.getComponent(_components.Cullable);
|
|
571
|
+
return this.style.visibility === 'visible' && (!cullable || cullable && !cullable.isCulled());
|
|
574
572
|
};
|
|
575
573
|
/**
|
|
576
574
|
* bring to front in current group
|
|
@@ -579,11 +577,12 @@ var DisplayObject = function (_super) {
|
|
|
579
577
|
|
|
580
578
|
DisplayObject.prototype.toFront = function () {
|
|
581
579
|
if (this.parentNode) {
|
|
582
|
-
|
|
580
|
+
this.style.zIndex = Math.max.apply(Math, (0, _tslib.__spreadArray)([], (0, _tslib.__read)(this.parentNode.children.map(function (child) {
|
|
583
581
|
return Number(child.style.zIndex);
|
|
584
582
|
})))) + 1;
|
|
585
|
-
this.setZIndex(zIndex);
|
|
586
583
|
}
|
|
584
|
+
|
|
585
|
+
return this;
|
|
587
586
|
};
|
|
588
587
|
/**
|
|
589
588
|
* send to back in current group
|
|
@@ -592,34 +591,85 @@ var DisplayObject = function (_super) {
|
|
|
592
591
|
|
|
593
592
|
DisplayObject.prototype.toBack = function () {
|
|
594
593
|
if (this.parentNode) {
|
|
595
|
-
|
|
594
|
+
this.style.zIndex = Math.min.apply(Math, (0, _tslib.__spreadArray)([], (0, _tslib.__read)(this.parentNode.children.map(function (child) {
|
|
596
595
|
return Number(child.style.zIndex);
|
|
597
596
|
})))) - 1;
|
|
598
|
-
this.setZIndex(zIndex);
|
|
599
597
|
}
|
|
598
|
+
|
|
599
|
+
return this;
|
|
600
|
+
}; // #endregion visible
|
|
601
|
+
// #region deprecated
|
|
602
|
+
|
|
603
|
+
/**
|
|
604
|
+
* @deprecated
|
|
605
|
+
* compatible with G 3.0
|
|
606
|
+
* @deprecated
|
|
607
|
+
*/
|
|
608
|
+
|
|
609
|
+
|
|
610
|
+
DisplayObject.prototype.getCount = function () {
|
|
611
|
+
return this.childElementCount;
|
|
600
612
|
};
|
|
601
613
|
/**
|
|
602
|
-
*
|
|
603
|
-
*
|
|
604
|
-
* @
|
|
614
|
+
* @deprecated
|
|
615
|
+
* compatible with G 3.0
|
|
616
|
+
* @deprecated
|
|
605
617
|
*/
|
|
606
618
|
|
|
607
619
|
|
|
608
|
-
DisplayObject.prototype.
|
|
609
|
-
this.
|
|
620
|
+
DisplayObject.prototype.getParent = function () {
|
|
621
|
+
return this.parentElement;
|
|
610
622
|
};
|
|
611
623
|
/**
|
|
612
|
-
*
|
|
624
|
+
* @deprecated
|
|
625
|
+
* compatible with G 3.0
|
|
626
|
+
* @deprecated
|
|
613
627
|
*/
|
|
614
628
|
|
|
615
629
|
|
|
616
|
-
DisplayObject.prototype.
|
|
617
|
-
this.
|
|
630
|
+
DisplayObject.prototype.getChildren = function () {
|
|
631
|
+
return this.children;
|
|
632
|
+
};
|
|
633
|
+
/**
|
|
634
|
+
* @deprecated
|
|
635
|
+
* compatible with G 3.0
|
|
636
|
+
* @deprecated
|
|
637
|
+
*/
|
|
638
|
+
|
|
639
|
+
|
|
640
|
+
DisplayObject.prototype.getFirst = function () {
|
|
641
|
+
return this.firstElementChild;
|
|
618
642
|
};
|
|
643
|
+
/**
|
|
644
|
+
* @deprecated
|
|
645
|
+
* compatible with G 3.0
|
|
646
|
+
* @deprecated
|
|
647
|
+
* get last child group/shape
|
|
648
|
+
*/
|
|
619
649
|
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
return this.
|
|
650
|
+
|
|
651
|
+
DisplayObject.prototype.getLast = function () {
|
|
652
|
+
return this.lastElementChild;
|
|
653
|
+
};
|
|
654
|
+
/**
|
|
655
|
+
* @deprecated
|
|
656
|
+
* compatible with G 3.0
|
|
657
|
+
* @deprecated
|
|
658
|
+
* get child group/shape by index
|
|
659
|
+
*/
|
|
660
|
+
|
|
661
|
+
|
|
662
|
+
DisplayObject.prototype.getChildByIndex = function (index) {
|
|
663
|
+
return this.children[index] || null;
|
|
664
|
+
};
|
|
665
|
+
/**
|
|
666
|
+
* compatible with G 3.0
|
|
667
|
+
* @deprecated
|
|
668
|
+
*/
|
|
669
|
+
|
|
670
|
+
|
|
671
|
+
DisplayObject.prototype.add = function (child, index) {
|
|
672
|
+
return this.appendChild(child, index);
|
|
623
673
|
};
|
|
624
674
|
/**
|
|
625
675
|
* @alias style.clipPath
|
|
@@ -637,116 +687,185 @@ var DisplayObject = function (_super) {
|
|
|
637
687
|
|
|
638
688
|
|
|
639
689
|
DisplayObject.prototype.getClip = function () {
|
|
640
|
-
return this.style.clipPath;
|
|
690
|
+
return this.style.clipPath || null;
|
|
641
691
|
};
|
|
642
692
|
/**
|
|
643
|
-
*
|
|
644
|
-
*
|
|
645
|
-
* * translateX: '10px' => { unit: 'px', value: 10 }
|
|
693
|
+
* compatible with G 3.0
|
|
694
|
+
* @deprecated
|
|
646
695
|
*/
|
|
647
696
|
|
|
648
697
|
|
|
649
|
-
DisplayObject.prototype.
|
|
650
|
-
|
|
698
|
+
DisplayObject.prototype.set = function (name, value) {
|
|
699
|
+
this.config[name] = value;
|
|
700
|
+
};
|
|
701
|
+
/**
|
|
702
|
+
* compatible with G 3.0
|
|
703
|
+
* @deprecated
|
|
704
|
+
*/
|
|
651
705
|
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
this.parsedStyle[name] = value;
|
|
656
|
-
}
|
|
706
|
+
|
|
707
|
+
DisplayObject.prototype.get = function (name) {
|
|
708
|
+
return this.config[name];
|
|
657
709
|
};
|
|
710
|
+
/**
|
|
711
|
+
* compatible with G 3.0
|
|
712
|
+
* @alias object.config
|
|
713
|
+
* @deprecated
|
|
714
|
+
*/
|
|
658
715
|
|
|
659
|
-
DisplayObject.prototype.updateStyleProperty = function (name, oldParsedValue, newParsedValue) {
|
|
660
|
-
var _this = this; // update property, which may cause AABB re-calc
|
|
661
|
-
// @ts-ignore
|
|
662
716
|
|
|
717
|
+
DisplayObject.prototype.getConfig = function () {
|
|
718
|
+
return this.config;
|
|
719
|
+
};
|
|
663
720
|
|
|
664
|
-
|
|
721
|
+
DisplayObject.prototype.attr = function () {
|
|
722
|
+
var _this = this;
|
|
665
723
|
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
724
|
+
var args = [];
|
|
725
|
+
|
|
726
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
727
|
+
args[_i] = arguments[_i];
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
var _a = (0, _tslib.__read)(args, 2),
|
|
731
|
+
name = _a[0],
|
|
732
|
+
value = _a[1];
|
|
733
|
+
|
|
734
|
+
if (!name) {
|
|
735
|
+
return this.attributes;
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
if ((0, _util.isObject)(name)) {
|
|
739
|
+
Object.keys(name).forEach(function (key) {
|
|
740
|
+
_this.setAttribute(key, name[key]);
|
|
669
741
|
});
|
|
742
|
+
return this;
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
if (args.length === 2) {
|
|
746
|
+
this.setAttribute(name, value);
|
|
747
|
+
return this;
|
|
670
748
|
}
|
|
749
|
+
|
|
750
|
+
return this.attributes[name];
|
|
671
751
|
};
|
|
672
752
|
/**
|
|
673
|
-
*
|
|
753
|
+
* @alias setPosition
|
|
754
|
+
* @deprecated
|
|
674
755
|
*/
|
|
675
756
|
|
|
676
757
|
|
|
677
|
-
DisplayObject.prototype.
|
|
678
|
-
|
|
758
|
+
DisplayObject.prototype.moveTo = function (position, y, z) {
|
|
759
|
+
if (y === void 0) {
|
|
760
|
+
y = 0;
|
|
761
|
+
}
|
|
679
762
|
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
763
|
+
if (z === void 0) {
|
|
764
|
+
z = 0;
|
|
765
|
+
}
|
|
683
766
|
|
|
684
|
-
|
|
767
|
+
this.setPosition(position, y, z);
|
|
768
|
+
return this;
|
|
769
|
+
};
|
|
770
|
+
/**
|
|
771
|
+
* @alias setPosition
|
|
772
|
+
* @deprecated
|
|
773
|
+
*/
|
|
685
774
|
|
|
686
|
-
this.attributes[name] = value; // @ts-ignore
|
|
687
775
|
|
|
688
|
-
|
|
776
|
+
DisplayObject.prototype.move = function (position, y, z) {
|
|
777
|
+
if (y === void 0) {
|
|
778
|
+
y = 0;
|
|
779
|
+
}
|
|
689
780
|
|
|
690
|
-
|
|
781
|
+
if (z === void 0) {
|
|
782
|
+
z = 0;
|
|
783
|
+
}
|
|
691
784
|
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
} // redraw at next frame
|
|
785
|
+
this.setPosition(position, y, z);
|
|
786
|
+
return this;
|
|
787
|
+
};
|
|
788
|
+
/**
|
|
789
|
+
* @alias style.zIndex
|
|
790
|
+
* @deprecated
|
|
791
|
+
*/
|
|
700
792
|
|
|
701
793
|
|
|
702
|
-
|
|
703
|
-
this.
|
|
794
|
+
DisplayObject.prototype.setZIndex = function (zIndex) {
|
|
795
|
+
this.style.zIndex = zIndex;
|
|
796
|
+
return this;
|
|
704
797
|
};
|
|
798
|
+
/**
|
|
799
|
+
* return 3x3 matrix in world space
|
|
800
|
+
* @deprecated
|
|
801
|
+
*/
|
|
705
802
|
|
|
706
|
-
DisplayObject.prototype.initAttributes = function (attributes) {
|
|
707
|
-
var _this = this;
|
|
708
803
|
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
}
|
|
804
|
+
DisplayObject.prototype.getMatrix = function () {
|
|
805
|
+
var transform = this.getWorldTransform();
|
|
712
806
|
|
|
713
|
-
var
|
|
714
|
-
|
|
807
|
+
var _a = (0, _tslib.__read)(_glMatrix.mat4.getTranslation(_glMatrix.vec3.create(), transform), 2),
|
|
808
|
+
tx = _a[0],
|
|
809
|
+
ty = _a[1];
|
|
715
810
|
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
811
|
+
var _b = (0, _tslib.__read)(_glMatrix.mat4.getScaling(_glMatrix.vec3.create(), transform), 2),
|
|
812
|
+
sx = _b[0],
|
|
813
|
+
sy = _b[1];
|
|
719
814
|
|
|
720
|
-
|
|
721
|
-
}
|
|
815
|
+
var rotation = _glMatrix.mat4.getRotation(_glMatrix.quat.create(), transform);
|
|
722
816
|
|
|
723
|
-
var
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
817
|
+
var _c = (0, _tslib.__read)((0, _utils.getEuler)(_glMatrix.vec3.create(), rotation), 3),
|
|
818
|
+
eux = _c[0],
|
|
819
|
+
euy = _c[1],
|
|
820
|
+
euz = _c[2]; // gimbal lock at 90 degrees
|
|
727
821
|
|
|
728
|
-
var sortedNames = Object.keys(attributes).sort(function (a, b) {
|
|
729
|
-
return (priorities[a] || 0) - (priorities[b] || 0);
|
|
730
|
-
});
|
|
731
|
-
sortedNames.forEach(function (attributeName) {
|
|
732
|
-
// @ts-ignore
|
|
733
|
-
_this.updateStyleProperty(attributeName, undefined, _this.parsedStyle[attributeName]);
|
|
734
|
-
}); // redraw at next frame
|
|
735
822
|
|
|
736
|
-
|
|
823
|
+
return (0, _utils.fromRotationTranslationScale)(eux || euz, tx, ty, sx, sy);
|
|
737
824
|
};
|
|
738
825
|
/**
|
|
739
|
-
*
|
|
826
|
+
* set 3x3 matrix in world space
|
|
827
|
+
* @deprecated
|
|
740
828
|
*/
|
|
741
829
|
|
|
742
830
|
|
|
743
|
-
DisplayObject.prototype.
|
|
744
|
-
var
|
|
745
|
-
|
|
746
|
-
|
|
831
|
+
DisplayObject.prototype.setMatrix = function (mat) {
|
|
832
|
+
var row0x = mat[0];
|
|
833
|
+
var row0y = mat[3];
|
|
834
|
+
var row1x = mat[1];
|
|
835
|
+
var row1y = mat[4]; // decompose 3x3 matrix
|
|
836
|
+
// @see https://www.w3.org/TR/css-transforms-1/#decomposing-a-2d-matrix
|
|
837
|
+
|
|
838
|
+
var scalingX = Math.sqrt(row0x * row0x + row0y * row0y);
|
|
839
|
+
var scalingY = Math.sqrt(row1x * row1x + row1y * row1y); // If determinant is negative, one axis was flipped.
|
|
840
|
+
|
|
841
|
+
var determinant = row0x * row1y - row0y * row1x;
|
|
842
|
+
|
|
843
|
+
if (determinant < 0) {
|
|
844
|
+
// Flip axis with minimum unit vector dot product.
|
|
845
|
+
if (row0x < row1y) {
|
|
846
|
+
scalingX = -scalingX;
|
|
847
|
+
} else {
|
|
848
|
+
scalingY = -scalingY;
|
|
849
|
+
}
|
|
850
|
+
} // Renormalize matrix to remove scale.
|
|
851
|
+
|
|
852
|
+
|
|
853
|
+
if (scalingX) {
|
|
854
|
+
row0x *= 1 / scalingX;
|
|
855
|
+
row0y *= 1 / scalingX;
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
if (scalingY) {
|
|
859
|
+
row1x *= 1 / scalingY;
|
|
860
|
+
row1y *= 1 / scalingY;
|
|
861
|
+
} // Compute rotation and renormalize matrix.
|
|
862
|
+
|
|
863
|
+
|
|
864
|
+
var angle = Math.atan2(row0y, row0x);
|
|
865
|
+
this.setEulerAngles(angle).setPosition(mat[6], mat[7]).setLocalScale(scalingX, scalingY);
|
|
747
866
|
};
|
|
748
867
|
|
|
749
868
|
return DisplayObject;
|
|
750
|
-
}(
|
|
869
|
+
}(_dom.Element);
|
|
751
870
|
|
|
752
871
|
exports.DisplayObject = DisplayObject;
|