@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
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
import { __assign, __extends, __read, __spreadArray } from "tslib";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { SHAPE } from '
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
2
|
+
import { isEqual, isNil, isObject } from '@antv/util';
|
|
3
|
+
import { mat4, quat, vec3 } from 'gl-matrix';
|
|
4
|
+
import { DisplayObjectPool } from '../DisplayObjectPool';
|
|
5
|
+
import { Element, ElementEvent, KeyframeEffect } from '../dom';
|
|
6
|
+
import { container, SHAPE } from '..';
|
|
7
|
+
import { createVec3, fromRotationTranslationScale, getEuler, rad2deg } from '../utils';
|
|
8
|
+
import { Cullable, Renderable } from '../components';
|
|
9
|
+
import { StylePropertyParserFactory, StylePropertyUpdaterFactory } from '../property-handlers';
|
|
10
|
+
import { dirtifyRenderable } from '../services';
|
|
11
|
+
var DEFAULT_STYLE_PROPS = {
|
|
12
|
+
anchor: [0, 0, 0],
|
|
13
|
+
origin: [0, 0, 0],
|
|
14
|
+
opacity: 1,
|
|
15
|
+
fillOpacity: 1,
|
|
16
|
+
strokeOpacity: 1
|
|
17
|
+
};
|
|
11
18
|
/**
|
|
12
19
|
* prototype chains: DisplayObject -> Element -> Node -> EventTarget
|
|
13
20
|
*
|
|
21
|
+
* mixins: Animatable, Transformable, Visible
|
|
22
|
+
* @see https://github.com/tannerntannern/ts-mixer/blob/master/README.md#mixing-generic-classes
|
|
23
|
+
*
|
|
14
24
|
* Provide abilities in scene graph, such as:
|
|
15
25
|
* * transform `translate/rotate/scale`
|
|
16
26
|
* * add/remove child
|
|
@@ -30,27 +40,18 @@ var DisplayObject = function (_super) {
|
|
|
30
40
|
function DisplayObject(config) {
|
|
31
41
|
var _a, _b, _c;
|
|
32
42
|
|
|
33
|
-
var _this = _super.call(this) || this;
|
|
34
|
-
|
|
35
|
-
_this.shadow = false;
|
|
36
|
-
_this.displayObjectPool = container.get(DisplayObjectPool);
|
|
37
|
-
_this.stylePropertyUpdaterFactory = container.get(StylePropertyUpdaterFactory);
|
|
38
|
-
_this.stylePropertyParserFactory = container.get(StylePropertyParserFactory);
|
|
39
|
-
/** scene graph operations */
|
|
40
|
-
|
|
41
|
-
_this.scrollLeft = 0;
|
|
42
|
-
_this.scrollTop = 0;
|
|
43
|
+
var _this = _super.call(this, config) || this;
|
|
43
44
|
/**
|
|
44
|
-
*
|
|
45
|
+
* push to active animations after calling `animate()`
|
|
45
46
|
*/
|
|
46
47
|
|
|
47
|
-
_this.dataset = {}; // assign name, id to config
|
|
48
|
-
// eg. group.get('name')
|
|
49
|
-
|
|
50
|
-
_this.config = config; // insert this group into pool
|
|
51
48
|
|
|
52
|
-
_this.
|
|
49
|
+
_this.activeAnimations = [];
|
|
50
|
+
_this.stylePropertyUpdaterFactory = container.get(StylePropertyUpdaterFactory);
|
|
51
|
+
_this.stylePropertyParserFactory = container.get(StylePropertyParserFactory); // assign name, id to config
|
|
52
|
+
// eg. group.get('name')
|
|
53
53
|
|
|
54
|
+
_this.config = config; // compatible with G 3.0
|
|
54
55
|
|
|
55
56
|
_this.config.interactive = (_a = _this.config.capture) !== null && _a !== void 0 ? _a : _this.config.interactive; // init scene graph node
|
|
56
57
|
|
|
@@ -58,14 +59,12 @@ var DisplayObject = function (_super) {
|
|
|
58
59
|
_this.name = _this.config.name || '';
|
|
59
60
|
_this.className = _this.config.className || '';
|
|
60
61
|
_this.interactive = (_b = _this.config.interactive) !== null && _b !== void 0 ? _b : true;
|
|
61
|
-
_this.nodeName = _this.config.type || SHAPE.Group;
|
|
62
|
-
_this.attributes; // compatible with G 3.0
|
|
63
|
-
// @ts-ignore
|
|
62
|
+
_this.nodeName = _this.config.type || SHAPE.Group; // compatible with G 3.0
|
|
64
63
|
|
|
65
|
-
_this.config.style = __assign(__assign({
|
|
64
|
+
_this.config.style = __assign(__assign(__assign(__assign({}, DEFAULT_STYLE_PROPS), {
|
|
66
65
|
zIndex: (_c = _this.config.zIndex) !== null && _c !== void 0 ? _c : 0,
|
|
67
66
|
visibility: _this.config.visible === false ? 'hidden' : 'visible'
|
|
68
|
-
}, _this.config.style), _this.config.attrs);
|
|
67
|
+
}), _this.config.style), _this.config.attrs);
|
|
69
68
|
_this.style = new Proxy(_this.attributes, {
|
|
70
69
|
get: function get(_, prop) {
|
|
71
70
|
return _this.getAttribute(prop);
|
|
@@ -77,179 +76,170 @@ var DisplayObject = function (_super) {
|
|
|
77
76
|
}
|
|
78
77
|
});
|
|
79
78
|
|
|
80
|
-
_this.initAttributes(_this.config.style);
|
|
79
|
+
_this.initAttributes(_this.config.style); // insert this group into pool
|
|
81
80
|
|
|
82
|
-
_this.on(DISPLAY_OBJECT_EVENT.ChildInserted, function (child) {
|
|
83
|
-
// when appending to document
|
|
84
|
-
if (_this.ownerDocument && _this.ownerDocument.documentElement === _this && _this.ownerDocument.defaultView) {
|
|
85
|
-
_this.ownerDocument.defaultView.decorate(child, _this.ownerDocument.defaultView.getRenderingService(), _this);
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
81
|
|
|
82
|
+
container.get(DisplayObjectPool).add(_this.entity.getName(), _this);
|
|
89
83
|
return _this;
|
|
90
84
|
}
|
|
91
|
-
/**
|
|
92
|
-
* compatible with G 3.0
|
|
93
|
-
* @deprecated
|
|
94
|
-
*/
|
|
95
85
|
|
|
86
|
+
DisplayObject.prototype.destroy = function () {
|
|
87
|
+
_super.prototype.destroy.call(this); // remove from into pool
|
|
96
88
|
|
|
97
|
-
DisplayObject.prototype.set = function (name, value) {
|
|
98
|
-
this.config[name] = value;
|
|
99
|
-
};
|
|
100
89
|
|
|
101
|
-
|
|
102
|
-
return this.config[name];
|
|
103
|
-
};
|
|
90
|
+
container.get(DisplayObjectPool).remove(this.entity.getName()); // stop all active animations
|
|
104
91
|
|
|
105
|
-
|
|
106
|
-
|
|
92
|
+
this.getAnimations().forEach(function (animation) {
|
|
93
|
+
animation.cancel();
|
|
94
|
+
});
|
|
107
95
|
};
|
|
108
96
|
|
|
109
|
-
DisplayObject.prototype.
|
|
110
|
-
var
|
|
111
|
-
|
|
112
|
-
|
|
97
|
+
DisplayObject.prototype.cloneNode = function (deep) {
|
|
98
|
+
var cloned = new this.constructor({
|
|
99
|
+
// copy id & name
|
|
100
|
+
// @see https://developer.mozilla.org/en-US/docs/Web/API/Node/cloneNode#notes
|
|
101
|
+
id: this.id,
|
|
102
|
+
name: this.name,
|
|
103
|
+
className: this.name,
|
|
104
|
+
interactive: this.interactive,
|
|
105
|
+
style: __assign({}, this.style)
|
|
106
|
+
});
|
|
113
107
|
|
|
114
|
-
|
|
115
|
-
|
|
108
|
+
if (deep) {
|
|
109
|
+
this.children.forEach(function (child) {
|
|
110
|
+
var clonedChild = child.cloneNode(deep);
|
|
111
|
+
cloned.appendChild(clonedChild);
|
|
112
|
+
});
|
|
116
113
|
}
|
|
117
114
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
value = _a[1];
|
|
115
|
+
return cloned;
|
|
116
|
+
};
|
|
121
117
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
118
|
+
DisplayObject.prototype.initAttributes = function (attributes) {
|
|
119
|
+
var _this = this;
|
|
125
120
|
|
|
126
|
-
if (
|
|
127
|
-
|
|
128
|
-
_this.setAttribute(key, name[key]);
|
|
129
|
-
});
|
|
130
|
-
return this;
|
|
121
|
+
if (attributes === void 0) {
|
|
122
|
+
attributes = {};
|
|
131
123
|
}
|
|
132
124
|
|
|
133
|
-
|
|
134
|
-
this.setAttribute(name, value);
|
|
135
|
-
return this;
|
|
136
|
-
}
|
|
125
|
+
var renderable = this.entity.getComponent(Renderable); // parse attributes first
|
|
137
126
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
* @deprecated
|
|
142
|
-
* compatible with G 3.0
|
|
143
|
-
* @deprecated
|
|
144
|
-
*/
|
|
127
|
+
for (var attributeName in attributes) {
|
|
128
|
+
var value = attributes[attributeName];
|
|
129
|
+
this.attributes[attributeName] = value; // @ts-ignore
|
|
145
130
|
|
|
131
|
+
this.parseStyleProperty(attributeName, value);
|
|
132
|
+
}
|
|
146
133
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
* @deprecated
|
|
152
|
-
* compatible with G 3.0
|
|
153
|
-
* @deprecated
|
|
154
|
-
*/
|
|
134
|
+
var priorities = {
|
|
135
|
+
x: 1000,
|
|
136
|
+
y: 1000
|
|
137
|
+
}; // update x, y at last
|
|
155
138
|
|
|
139
|
+
var sortedNames = Object.keys(attributes).sort(function (a, b) {
|
|
140
|
+
return (priorities[a] || 0) - (priorities[b] || 0);
|
|
141
|
+
});
|
|
142
|
+
sortedNames.forEach(function (attributeName) {
|
|
143
|
+
// @ts-ignore
|
|
144
|
+
_this.updateStyleProperty(attributeName, undefined, _this.parsedStyle[attributeName]);
|
|
145
|
+
}); // redraw at next frame
|
|
156
146
|
|
|
157
|
-
|
|
158
|
-
return this.parentNode;
|
|
147
|
+
renderable.dirty = true;
|
|
159
148
|
};
|
|
160
|
-
/**
|
|
161
|
-
* @deprecated
|
|
162
|
-
* compatible with G 3.0
|
|
163
|
-
* @deprecated
|
|
164
|
-
*/
|
|
165
149
|
|
|
150
|
+
DisplayObject.prototype.setAttribute = function (attributeName, value, force) {
|
|
151
|
+
if (force === void 0) {
|
|
152
|
+
force = false;
|
|
153
|
+
}
|
|
166
154
|
|
|
167
|
-
|
|
168
|
-
|
|
155
|
+
if (force || !isEqual(value, this.attributes[attributeName]) || attributeName === 'transformOrigin' || attributeName === 'visibility' // will affect children
|
|
156
|
+
) {
|
|
157
|
+
if (attributeName === 'visibility') {
|
|
158
|
+
// set value cascade
|
|
159
|
+
this.forEach(function (object) {
|
|
160
|
+
object.changeAttribute(attributeName, value);
|
|
161
|
+
});
|
|
162
|
+
} else {
|
|
163
|
+
this.changeAttribute(attributeName, value);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
_super.prototype.setAttribute.call(this, attributeName, value);
|
|
167
|
+
}
|
|
169
168
|
};
|
|
170
169
|
/**
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
170
|
+
* parse property, eg.
|
|
171
|
+
* * fill: 'red' => [1, 0, 0, 1]
|
|
172
|
+
* * translateX: '10px' => { unit: 'px', value: 10 }
|
|
174
173
|
*/
|
|
175
174
|
|
|
176
175
|
|
|
177
|
-
DisplayObject.prototype.
|
|
178
|
-
|
|
176
|
+
DisplayObject.prototype.parseStyleProperty = function (name, value) {
|
|
177
|
+
var stylePropertyParser = this.stylePropertyParserFactory(name);
|
|
178
|
+
|
|
179
|
+
if (stylePropertyParser) {
|
|
180
|
+
// @ts-ignore
|
|
181
|
+
this.parsedStyle[name] = stylePropertyParser(value, this);
|
|
182
|
+
} else {
|
|
183
|
+
this.parsedStyle[name] = value;
|
|
184
|
+
}
|
|
179
185
|
};
|
|
180
|
-
/**
|
|
181
|
-
* @deprecated
|
|
182
|
-
* compatible with G 3.0
|
|
183
|
-
* @deprecated
|
|
184
|
-
* get last child group/shape
|
|
185
|
-
*/
|
|
186
186
|
|
|
187
|
+
DisplayObject.prototype.updateStyleProperty = function (name, oldParsedValue, newParsedValue) {
|
|
188
|
+
var _this = this; // update property, which may cause AABB re-calc
|
|
189
|
+
// @ts-ignore
|
|
187
190
|
|
|
188
|
-
DisplayObject.prototype.getLast = function () {
|
|
189
|
-
return this.lastChild;
|
|
190
|
-
};
|
|
191
|
-
/**
|
|
192
|
-
* @deprecated
|
|
193
|
-
* compatible with G 3.0
|
|
194
|
-
* @deprecated
|
|
195
|
-
* get child group/shape by index
|
|
196
|
-
*/
|
|
197
191
|
|
|
192
|
+
var stylePropertyUpdaters = this.stylePropertyUpdaterFactory(name);
|
|
198
193
|
|
|
199
|
-
|
|
200
|
-
|
|
194
|
+
if (stylePropertyUpdaters) {
|
|
195
|
+
stylePropertyUpdaters.forEach(function (updater) {
|
|
196
|
+
// @ts-ignore
|
|
197
|
+
updater(oldParsedValue, newParsedValue, _this, _this.sceneGraphService);
|
|
198
|
+
});
|
|
199
|
+
}
|
|
201
200
|
};
|
|
202
201
|
/**
|
|
203
|
-
*
|
|
204
|
-
* @deprecated
|
|
202
|
+
* called when attributes get changed or initialized
|
|
205
203
|
*/
|
|
206
204
|
|
|
207
205
|
|
|
208
|
-
DisplayObject.prototype.
|
|
209
|
-
this
|
|
210
|
-
};
|
|
211
|
-
/** transform operations */
|
|
212
|
-
|
|
206
|
+
DisplayObject.prototype.changeAttribute = function (name, value) {
|
|
207
|
+
var _this = this;
|
|
213
208
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
}
|
|
209
|
+
var entity = this.getEntity();
|
|
210
|
+
var renderable = entity.getComponent(Renderable);
|
|
211
|
+
var oldValue = this.attributes[name]; // @ts-ignore
|
|
218
212
|
|
|
219
|
-
|
|
220
|
-
z = 0;
|
|
221
|
-
}
|
|
213
|
+
var oldParsedValue = this.parsedStyle[name]; // update value
|
|
222
214
|
|
|
223
|
-
this.
|
|
224
|
-
return this;
|
|
225
|
-
};
|
|
215
|
+
this.attributes[name] = value; // @ts-ignore
|
|
226
216
|
|
|
227
|
-
|
|
228
|
-
return this.sceneGraphService.getOrigin(this);
|
|
229
|
-
};
|
|
230
|
-
/**
|
|
231
|
-
* alias setPosition
|
|
232
|
-
*/
|
|
217
|
+
this.parseStyleProperty(name, value); // @ts-ignore
|
|
233
218
|
|
|
219
|
+
this.updateStyleProperty(name, oldParsedValue, this.parsedStyle[name]); // inform clip path targets
|
|
234
220
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
221
|
+
if (this.attributes.clipPathTargets && this.attributes.clipPathTargets.length) {
|
|
222
|
+
this.attributes.clipPathTargets.forEach(function (target) {
|
|
223
|
+
dirtifyRenderable(target);
|
|
224
|
+
target.emit(ElementEvent.ATTRIBUTE_CHANGED, {
|
|
225
|
+
attributeName: 'clipPath',
|
|
226
|
+
oldValue: _this,
|
|
227
|
+
newValue: _this
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
} // redraw at next frame
|
|
239
231
|
|
|
240
|
-
if (z === void 0) {
|
|
241
|
-
z = 0;
|
|
242
|
-
}
|
|
243
232
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
233
|
+
renderable.dirty = true;
|
|
234
|
+
this.emit(ElementEvent.ATTRIBUTE_CHANGED, {
|
|
235
|
+
attributeName: name,
|
|
236
|
+
oldValue: oldValue,
|
|
237
|
+
newValue: value
|
|
238
|
+
});
|
|
239
|
+
}; // #region transformable
|
|
250
240
|
|
|
251
241
|
|
|
252
|
-
DisplayObject.prototype.
|
|
242
|
+
DisplayObject.prototype.setOrigin = function (position, y, z) {
|
|
253
243
|
if (y === void 0) {
|
|
254
244
|
y = 0;
|
|
255
245
|
}
|
|
@@ -258,12 +248,15 @@ var DisplayObject = function (_super) {
|
|
|
258
248
|
z = 0;
|
|
259
249
|
}
|
|
260
250
|
|
|
261
|
-
this.
|
|
251
|
+
this.sceneGraphService.setOrigin(this, createVec3(position, y, z));
|
|
252
|
+
this.attributes.origin = this.getOrigin();
|
|
262
253
|
return this;
|
|
263
254
|
};
|
|
255
|
+
|
|
256
|
+
DisplayObject.prototype.getOrigin = function () {
|
|
257
|
+
return this.sceneGraphService.getOrigin(this);
|
|
258
|
+
};
|
|
264
259
|
/**
|
|
265
|
-
* compatible with G 3.0
|
|
266
|
-
*
|
|
267
260
|
* set position in world space
|
|
268
261
|
*/
|
|
269
262
|
|
|
@@ -404,9 +397,8 @@ var DisplayObject = function (_super) {
|
|
|
404
397
|
|
|
405
398
|
|
|
406
399
|
DisplayObject.prototype.getEulerAngles = function () {
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
var _a = __read(getEuler(vec3.create(), this.sceneGraphService.getWorldTransform(this, transform)), 3),
|
|
400
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
401
|
+
var _a = __read(getEuler(vec3.create(), this.sceneGraphService.getWorldTransform(this)), 3),
|
|
410
402
|
ex = _a[0],
|
|
411
403
|
ey = _a[1],
|
|
412
404
|
ez = _a[2];
|
|
@@ -481,80 +473,83 @@ var DisplayObject = function (_super) {
|
|
|
481
473
|
DisplayObject.prototype.getWorldTransform = function () {
|
|
482
474
|
return this.sceneGraphService.getWorldTransform(this);
|
|
483
475
|
};
|
|
476
|
+
|
|
477
|
+
DisplayObject.prototype.resetLocalTransform = function () {
|
|
478
|
+
this.sceneGraphService.resetLocalTransform(this);
|
|
479
|
+
};
|
|
484
480
|
/**
|
|
485
|
-
*
|
|
486
|
-
*
|
|
481
|
+
* sync style.x/y when local position changed
|
|
482
|
+
*
|
|
483
|
+
* Mixins may not declare private/protected properties
|
|
484
|
+
* however, you can use ES2020 private fields
|
|
487
485
|
*/
|
|
488
486
|
|
|
489
487
|
|
|
490
|
-
DisplayObject.prototype.
|
|
491
|
-
var
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
var _b = __read(mat4.getScaling(vec3.create(), transform), 2),
|
|
498
|
-
sx = _b[0],
|
|
499
|
-
sy = _b[1];
|
|
500
|
-
|
|
501
|
-
var rotation = mat4.getRotation(quat.create(), transform);
|
|
488
|
+
DisplayObject.prototype.syncLocalPosition = function () {
|
|
489
|
+
var localPosition = this.getLocalPosition();
|
|
490
|
+
this.attributes.x = localPosition[0];
|
|
491
|
+
this.attributes.y = localPosition[1];
|
|
492
|
+
}; // #endregion transformable
|
|
493
|
+
// #region animatable
|
|
502
494
|
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
495
|
+
/**
|
|
496
|
+
* returns an array of all Animation objects affecting this element
|
|
497
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getAnimations
|
|
498
|
+
*/
|
|
507
499
|
|
|
508
500
|
|
|
509
|
-
|
|
501
|
+
DisplayObject.prototype.getAnimations = function () {
|
|
502
|
+
return this.activeAnimations;
|
|
510
503
|
};
|
|
511
504
|
/**
|
|
512
|
-
*
|
|
513
|
-
* @
|
|
505
|
+
* create an animation with WAAPI
|
|
506
|
+
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/animate
|
|
514
507
|
*/
|
|
515
508
|
|
|
516
509
|
|
|
517
|
-
DisplayObject.prototype.
|
|
518
|
-
var
|
|
519
|
-
var row0y = mat[3];
|
|
520
|
-
var row1x = mat[1];
|
|
521
|
-
var row1y = mat[4]; // decompose 3x3 matrix
|
|
522
|
-
// @see https://www.w3.org/TR/css-transforms-1/#decomposing-a-2d-matrix
|
|
510
|
+
DisplayObject.prototype.animate = function (keyframes, options) {
|
|
511
|
+
var _a, _b;
|
|
523
512
|
|
|
524
|
-
var
|
|
525
|
-
var scalingY = Math.sqrt(row1x * row1x + row1y * row1y); // If determinant is negative, one axis was flipped.
|
|
513
|
+
var timeline = (_a = this.ownerDocument) === null || _a === void 0 ? void 0 : _a.timeline; // accounte for clip path, use target's timeline
|
|
526
514
|
|
|
527
|
-
|
|
515
|
+
if (this.attributes.clipPathTargets && this.attributes.clipPathTargets.length) {
|
|
516
|
+
var target = this.attributes.clipPathTargets[0];
|
|
517
|
+
timeline = (_b = target.ownerDocument) === null || _b === void 0 ? void 0 : _b.timeline;
|
|
518
|
+
} // clear old parsed transform
|
|
528
519
|
|
|
529
|
-
if (determinant < 0) {
|
|
530
|
-
// Flip axis with minimum unit vector dot product.
|
|
531
|
-
if (row0x < row1y) {
|
|
532
|
-
scalingX = -scalingX;
|
|
533
|
-
} else {
|
|
534
|
-
scalingY = -scalingY;
|
|
535
|
-
}
|
|
536
|
-
} // Renormalize matrix to remove scale.
|
|
537
520
|
|
|
521
|
+
this.parsedStyle.transform = undefined;
|
|
538
522
|
|
|
539
|
-
if (
|
|
540
|
-
|
|
541
|
-
row0y *= 1 / scalingX;
|
|
523
|
+
if (timeline) {
|
|
524
|
+
return timeline.play(new KeyframeEffect(this, keyframes, options));
|
|
542
525
|
}
|
|
543
526
|
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
} // Compute rotation and renormalize matrix.
|
|
548
|
-
|
|
527
|
+
return null;
|
|
528
|
+
}; // #endregion animatable
|
|
529
|
+
// #region visible
|
|
549
530
|
|
|
550
|
-
|
|
551
|
-
|
|
531
|
+
/**
|
|
532
|
+
* show group, which will also change visibility of its children in sceneGraphNode
|
|
533
|
+
*
|
|
534
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/visibility
|
|
535
|
+
*/
|
|
536
|
+
|
|
537
|
+
|
|
538
|
+
DisplayObject.prototype.show = function () {
|
|
539
|
+
this.style.visibility = 'visible';
|
|
552
540
|
};
|
|
553
|
-
|
|
541
|
+
/**
|
|
542
|
+
* hide group, which will also change visibility of its children in sceneGraphNode
|
|
543
|
+
*/
|
|
554
544
|
|
|
555
545
|
|
|
556
|
-
DisplayObject.prototype.
|
|
557
|
-
this.style.
|
|
546
|
+
DisplayObject.prototype.hide = function () {
|
|
547
|
+
this.style.visibility = 'hidden';
|
|
548
|
+
};
|
|
549
|
+
|
|
550
|
+
DisplayObject.prototype.isVisible = function () {
|
|
551
|
+
var cullable = this.entity.getComponent(Cullable);
|
|
552
|
+
return this.style.visibility === 'visible' && (!cullable || cullable && !cullable.isCulled());
|
|
558
553
|
};
|
|
559
554
|
/**
|
|
560
555
|
* bring to front in current group
|
|
@@ -563,11 +558,12 @@ var DisplayObject = function (_super) {
|
|
|
563
558
|
|
|
564
559
|
DisplayObject.prototype.toFront = function () {
|
|
565
560
|
if (this.parentNode) {
|
|
566
|
-
|
|
561
|
+
this.style.zIndex = Math.max.apply(Math, __spreadArray([], __read(this.parentNode.children.map(function (child) {
|
|
567
562
|
return Number(child.style.zIndex);
|
|
568
563
|
})))) + 1;
|
|
569
|
-
this.setZIndex(zIndex);
|
|
570
564
|
}
|
|
565
|
+
|
|
566
|
+
return this;
|
|
571
567
|
};
|
|
572
568
|
/**
|
|
573
569
|
* send to back in current group
|
|
@@ -576,34 +572,85 @@ var DisplayObject = function (_super) {
|
|
|
576
572
|
|
|
577
573
|
DisplayObject.prototype.toBack = function () {
|
|
578
574
|
if (this.parentNode) {
|
|
579
|
-
|
|
575
|
+
this.style.zIndex = Math.min.apply(Math, __spreadArray([], __read(this.parentNode.children.map(function (child) {
|
|
580
576
|
return Number(child.style.zIndex);
|
|
581
577
|
})))) - 1;
|
|
582
|
-
this.setZIndex(zIndex);
|
|
583
578
|
}
|
|
579
|
+
|
|
580
|
+
return this;
|
|
581
|
+
}; // #endregion visible
|
|
582
|
+
// #region deprecated
|
|
583
|
+
|
|
584
|
+
/**
|
|
585
|
+
* @deprecated
|
|
586
|
+
* compatible with G 3.0
|
|
587
|
+
* @deprecated
|
|
588
|
+
*/
|
|
589
|
+
|
|
590
|
+
|
|
591
|
+
DisplayObject.prototype.getCount = function () {
|
|
592
|
+
return this.childElementCount;
|
|
584
593
|
};
|
|
585
594
|
/**
|
|
586
|
-
*
|
|
587
|
-
*
|
|
588
|
-
* @
|
|
595
|
+
* @deprecated
|
|
596
|
+
* compatible with G 3.0
|
|
597
|
+
* @deprecated
|
|
589
598
|
*/
|
|
590
599
|
|
|
591
600
|
|
|
592
|
-
DisplayObject.prototype.
|
|
593
|
-
this.
|
|
601
|
+
DisplayObject.prototype.getParent = function () {
|
|
602
|
+
return this.parentElement;
|
|
594
603
|
};
|
|
595
604
|
/**
|
|
596
|
-
*
|
|
605
|
+
* @deprecated
|
|
606
|
+
* compatible with G 3.0
|
|
607
|
+
* @deprecated
|
|
597
608
|
*/
|
|
598
609
|
|
|
599
610
|
|
|
600
|
-
DisplayObject.prototype.
|
|
601
|
-
this.
|
|
611
|
+
DisplayObject.prototype.getChildren = function () {
|
|
612
|
+
return this.children;
|
|
602
613
|
};
|
|
614
|
+
/**
|
|
615
|
+
* @deprecated
|
|
616
|
+
* compatible with G 3.0
|
|
617
|
+
* @deprecated
|
|
618
|
+
*/
|
|
603
619
|
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
return this.
|
|
620
|
+
|
|
621
|
+
DisplayObject.prototype.getFirst = function () {
|
|
622
|
+
return this.firstElementChild;
|
|
623
|
+
};
|
|
624
|
+
/**
|
|
625
|
+
* @deprecated
|
|
626
|
+
* compatible with G 3.0
|
|
627
|
+
* @deprecated
|
|
628
|
+
* get last child group/shape
|
|
629
|
+
*/
|
|
630
|
+
|
|
631
|
+
|
|
632
|
+
DisplayObject.prototype.getLast = function () {
|
|
633
|
+
return this.lastElementChild;
|
|
634
|
+
};
|
|
635
|
+
/**
|
|
636
|
+
* @deprecated
|
|
637
|
+
* compatible with G 3.0
|
|
638
|
+
* @deprecated
|
|
639
|
+
* get child group/shape by index
|
|
640
|
+
*/
|
|
641
|
+
|
|
642
|
+
|
|
643
|
+
DisplayObject.prototype.getChildByIndex = function (index) {
|
|
644
|
+
return this.children[index] || null;
|
|
645
|
+
};
|
|
646
|
+
/**
|
|
647
|
+
* compatible with G 3.0
|
|
648
|
+
* @deprecated
|
|
649
|
+
*/
|
|
650
|
+
|
|
651
|
+
|
|
652
|
+
DisplayObject.prototype.add = function (child, index) {
|
|
653
|
+
return this.appendChild(child, index);
|
|
607
654
|
};
|
|
608
655
|
/**
|
|
609
656
|
* @alias style.clipPath
|
|
@@ -621,113 +668,182 @@ var DisplayObject = function (_super) {
|
|
|
621
668
|
|
|
622
669
|
|
|
623
670
|
DisplayObject.prototype.getClip = function () {
|
|
624
|
-
return this.style.clipPath;
|
|
671
|
+
return this.style.clipPath || null;
|
|
625
672
|
};
|
|
626
673
|
/**
|
|
627
|
-
*
|
|
628
|
-
*
|
|
629
|
-
* * translateX: '10px' => { unit: 'px', value: 10 }
|
|
674
|
+
* compatible with G 3.0
|
|
675
|
+
* @deprecated
|
|
630
676
|
*/
|
|
631
677
|
|
|
632
678
|
|
|
633
|
-
DisplayObject.prototype.
|
|
634
|
-
|
|
679
|
+
DisplayObject.prototype.set = function (name, value) {
|
|
680
|
+
this.config[name] = value;
|
|
681
|
+
};
|
|
682
|
+
/**
|
|
683
|
+
* compatible with G 3.0
|
|
684
|
+
* @deprecated
|
|
685
|
+
*/
|
|
635
686
|
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
this.parsedStyle[name] = value;
|
|
640
|
-
}
|
|
687
|
+
|
|
688
|
+
DisplayObject.prototype.get = function (name) {
|
|
689
|
+
return this.config[name];
|
|
641
690
|
};
|
|
691
|
+
/**
|
|
692
|
+
* compatible with G 3.0
|
|
693
|
+
* @alias object.config
|
|
694
|
+
* @deprecated
|
|
695
|
+
*/
|
|
642
696
|
|
|
643
|
-
DisplayObject.prototype.updateStyleProperty = function (name, oldParsedValue, newParsedValue) {
|
|
644
|
-
var _this = this; // update property, which may cause AABB re-calc
|
|
645
|
-
// @ts-ignore
|
|
646
697
|
|
|
698
|
+
DisplayObject.prototype.getConfig = function () {
|
|
699
|
+
return this.config;
|
|
700
|
+
};
|
|
647
701
|
|
|
648
|
-
|
|
702
|
+
DisplayObject.prototype.attr = function () {
|
|
703
|
+
var _this = this;
|
|
649
704
|
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
705
|
+
var args = [];
|
|
706
|
+
|
|
707
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
708
|
+
args[_i] = arguments[_i];
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
var _a = __read(args, 2),
|
|
712
|
+
name = _a[0],
|
|
713
|
+
value = _a[1];
|
|
714
|
+
|
|
715
|
+
if (!name) {
|
|
716
|
+
return this.attributes;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
if (isObject(name)) {
|
|
720
|
+
Object.keys(name).forEach(function (key) {
|
|
721
|
+
_this.setAttribute(key, name[key]);
|
|
653
722
|
});
|
|
723
|
+
return this;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
if (args.length === 2) {
|
|
727
|
+
this.setAttribute(name, value);
|
|
728
|
+
return this;
|
|
654
729
|
}
|
|
730
|
+
|
|
731
|
+
return this.attributes[name];
|
|
655
732
|
};
|
|
656
733
|
/**
|
|
657
|
-
*
|
|
734
|
+
* @alias setPosition
|
|
735
|
+
* @deprecated
|
|
658
736
|
*/
|
|
659
737
|
|
|
660
738
|
|
|
661
|
-
DisplayObject.prototype.
|
|
662
|
-
|
|
739
|
+
DisplayObject.prototype.moveTo = function (position, y, z) {
|
|
740
|
+
if (y === void 0) {
|
|
741
|
+
y = 0;
|
|
742
|
+
}
|
|
663
743
|
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
744
|
+
if (z === void 0) {
|
|
745
|
+
z = 0;
|
|
746
|
+
}
|
|
667
747
|
|
|
668
|
-
|
|
748
|
+
this.setPosition(position, y, z);
|
|
749
|
+
return this;
|
|
750
|
+
};
|
|
751
|
+
/**
|
|
752
|
+
* @alias setPosition
|
|
753
|
+
* @deprecated
|
|
754
|
+
*/
|
|
669
755
|
|
|
670
|
-
this.attributes[name] = value; // @ts-ignore
|
|
671
756
|
|
|
672
|
-
|
|
757
|
+
DisplayObject.prototype.move = function (position, y, z) {
|
|
758
|
+
if (y === void 0) {
|
|
759
|
+
y = 0;
|
|
760
|
+
}
|
|
673
761
|
|
|
674
|
-
|
|
762
|
+
if (z === void 0) {
|
|
763
|
+
z = 0;
|
|
764
|
+
}
|
|
675
765
|
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
} // redraw at next frame
|
|
766
|
+
this.setPosition(position, y, z);
|
|
767
|
+
return this;
|
|
768
|
+
};
|
|
769
|
+
/**
|
|
770
|
+
* @alias style.zIndex
|
|
771
|
+
* @deprecated
|
|
772
|
+
*/
|
|
684
773
|
|
|
685
774
|
|
|
686
|
-
|
|
687
|
-
this.
|
|
775
|
+
DisplayObject.prototype.setZIndex = function (zIndex) {
|
|
776
|
+
this.style.zIndex = zIndex;
|
|
777
|
+
return this;
|
|
688
778
|
};
|
|
779
|
+
/**
|
|
780
|
+
* return 3x3 matrix in world space
|
|
781
|
+
* @deprecated
|
|
782
|
+
*/
|
|
689
783
|
|
|
690
|
-
DisplayObject.prototype.initAttributes = function (attributes) {
|
|
691
|
-
var _this = this;
|
|
692
784
|
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
}
|
|
785
|
+
DisplayObject.prototype.getMatrix = function () {
|
|
786
|
+
var transform = this.getWorldTransform();
|
|
696
787
|
|
|
697
|
-
var
|
|
698
|
-
|
|
788
|
+
var _a = __read(mat4.getTranslation(vec3.create(), transform), 2),
|
|
789
|
+
tx = _a[0],
|
|
790
|
+
ty = _a[1];
|
|
699
791
|
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
792
|
+
var _b = __read(mat4.getScaling(vec3.create(), transform), 2),
|
|
793
|
+
sx = _b[0],
|
|
794
|
+
sy = _b[1];
|
|
703
795
|
|
|
704
|
-
|
|
705
|
-
}
|
|
796
|
+
var rotation = mat4.getRotation(quat.create(), transform);
|
|
706
797
|
|
|
707
|
-
var
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
798
|
+
var _c = __read(getEuler(vec3.create(), rotation), 3),
|
|
799
|
+
eux = _c[0],
|
|
800
|
+
euy = _c[1],
|
|
801
|
+
euz = _c[2]; // gimbal lock at 90 degrees
|
|
711
802
|
|
|
712
|
-
var sortedNames = Object.keys(attributes).sort(function (a, b) {
|
|
713
|
-
return (priorities[a] || 0) - (priorities[b] || 0);
|
|
714
|
-
});
|
|
715
|
-
sortedNames.forEach(function (attributeName) {
|
|
716
|
-
// @ts-ignore
|
|
717
|
-
_this.updateStyleProperty(attributeName, undefined, _this.parsedStyle[attributeName]);
|
|
718
|
-
}); // redraw at next frame
|
|
719
803
|
|
|
720
|
-
|
|
804
|
+
return fromRotationTranslationScale(eux || euz, tx, ty, sx, sy);
|
|
721
805
|
};
|
|
722
806
|
/**
|
|
723
|
-
*
|
|
807
|
+
* set 3x3 matrix in world space
|
|
808
|
+
* @deprecated
|
|
724
809
|
*/
|
|
725
810
|
|
|
726
811
|
|
|
727
|
-
DisplayObject.prototype.
|
|
728
|
-
var
|
|
729
|
-
|
|
730
|
-
|
|
812
|
+
DisplayObject.prototype.setMatrix = function (mat) {
|
|
813
|
+
var row0x = mat[0];
|
|
814
|
+
var row0y = mat[3];
|
|
815
|
+
var row1x = mat[1];
|
|
816
|
+
var row1y = mat[4]; // decompose 3x3 matrix
|
|
817
|
+
// @see https://www.w3.org/TR/css-transforms-1/#decomposing-a-2d-matrix
|
|
818
|
+
|
|
819
|
+
var scalingX = Math.sqrt(row0x * row0x + row0y * row0y);
|
|
820
|
+
var scalingY = Math.sqrt(row1x * row1x + row1y * row1y); // If determinant is negative, one axis was flipped.
|
|
821
|
+
|
|
822
|
+
var determinant = row0x * row1y - row0y * row1x;
|
|
823
|
+
|
|
824
|
+
if (determinant < 0) {
|
|
825
|
+
// Flip axis with minimum unit vector dot product.
|
|
826
|
+
if (row0x < row1y) {
|
|
827
|
+
scalingX = -scalingX;
|
|
828
|
+
} else {
|
|
829
|
+
scalingY = -scalingY;
|
|
830
|
+
}
|
|
831
|
+
} // Renormalize matrix to remove scale.
|
|
832
|
+
|
|
833
|
+
|
|
834
|
+
if (scalingX) {
|
|
835
|
+
row0x *= 1 / scalingX;
|
|
836
|
+
row0y *= 1 / scalingX;
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
if (scalingY) {
|
|
840
|
+
row1x *= 1 / scalingY;
|
|
841
|
+
row1y *= 1 / scalingY;
|
|
842
|
+
} // Compute rotation and renormalize matrix.
|
|
843
|
+
|
|
844
|
+
|
|
845
|
+
var angle = Math.atan2(row0y, row0x);
|
|
846
|
+
this.setEulerAngles(angle).setPosition(mat[6], mat[7]).setLocalScale(scalingX, scalingY);
|
|
731
847
|
};
|
|
732
848
|
|
|
733
849
|
return DisplayObject;
|