@antv/g-lite 2.2.18 → 2.3.0
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/README.md +7 -7
- package/dist/index.esm.js +746 -615
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +747 -614
- package/dist/index.js.map +1 -1
- package/dist/index.umd.min.js +8 -6
- package/dist/index.umd.min.js.map +1 -1
- package/package.json +2 -2
- package/types/Canvas.d.ts +1 -0
- package/types/Canvas.d.ts.map +1 -1
- package/types/components/Transform.d.ts +8 -2
- package/types/components/Transform.d.ts.map +1 -1
- package/types/css/StyleValueRegistry.d.ts.map +1 -1
- package/types/css/properties/CSSPropertyTransform.d.ts.map +1 -1
- package/types/display-objects/DisplayObject.d.ts.map +1 -1
- package/types/dom/Element.d.ts +7 -6
- package/types/dom/Element.d.ts.map +1 -1
- package/types/dom/EventTarget.d.ts +2 -4
- package/types/dom/EventTarget.d.ts.map +1 -1
- package/types/dom/Node.d.ts +1 -0
- package/types/dom/Node.d.ts.map +1 -1
- package/types/dom/interfaces.d.ts +5 -0
- package/types/dom/interfaces.d.ts.map +1 -1
- package/types/global-runtime.d.ts.map +1 -1
- package/types/plugins/CullingPlugin.d.ts.map +1 -1
- package/types/plugins/PrepareRendererPlugin.d.ts +1 -0
- package/types/plugins/PrepareRendererPlugin.d.ts.map +1 -1
- package/types/services/RenderingContext.d.ts +1 -2
- package/types/services/RenderingContext.d.ts.map +1 -1
- package/types/services/RenderingService.d.ts +3 -0
- package/types/services/RenderingService.d.ts.map +1 -1
- package/types/services/SceneGraphService.d.ts +54 -55
- package/types/services/SceneGraphService.d.ts.map +1 -1
- package/types/services/TextService.d.ts.map +1 -1
- package/types/services/interfaces.d.ts +2 -2
- package/types/services/interfaces.d.ts.map +1 -1
- package/types/types.d.ts +25 -0
- package/types/types.d.ts.map +1 -1
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* @antv/g-lite
|
|
3
3
|
* @description A core module for rendering engine implements DOM API.
|
|
4
|
-
* @version 2.
|
|
5
|
-
* @date
|
|
4
|
+
* @version 2.3.0
|
|
5
|
+
* @date 6/27/2025, 8:31:48 AM
|
|
6
6
|
* @author AntVis
|
|
7
7
|
* @docs https://g.antv.antgroup.com/
|
|
8
8
|
*/
|
|
@@ -1230,18 +1230,18 @@ function getAngle(angle) {
|
|
|
1230
1230
|
}
|
|
1231
1231
|
return angle;
|
|
1232
1232
|
}
|
|
1233
|
-
var $vec3$
|
|
1233
|
+
var $vec3$3 = glMatrix.vec3.create();
|
|
1234
1234
|
function createVec3(x) {
|
|
1235
1235
|
var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
1236
1236
|
var z = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
1237
1237
|
var clone = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
|
|
1238
1238
|
if (Array.isArray(x) && x.length === 3) {
|
|
1239
|
-
return clone ? glMatrix.vec3.clone(x) : glMatrix.vec3.copy($vec3$
|
|
1239
|
+
return clone ? glMatrix.vec3.clone(x) : glMatrix.vec3.copy($vec3$3, x);
|
|
1240
1240
|
}
|
|
1241
1241
|
if (util.isNumber(x)) {
|
|
1242
|
-
return clone ? glMatrix.vec3.fromValues(x, y, z) : glMatrix.vec3.set($vec3$
|
|
1242
|
+
return clone ? glMatrix.vec3.fromValues(x, y, z) : glMatrix.vec3.set($vec3$3, x, y, z);
|
|
1243
1243
|
}
|
|
1244
|
-
return clone ? glMatrix.vec3.fromValues(x[0], x[1] || y, x[2] || z) : glMatrix.vec3.set($vec3$
|
|
1244
|
+
return clone ? glMatrix.vec3.fromValues(x[0], x[1] || y, x[2] || z) : glMatrix.vec3.set($vec3$3, x[0], x[1] || y, x[2] || z);
|
|
1245
1245
|
}
|
|
1246
1246
|
var DEG_RAD = Math.PI / 180;
|
|
1247
1247
|
function deg2rad(deg) {
|
|
@@ -2475,6 +2475,70 @@ var SortReason = /*#__PURE__*/function (SortReason) {
|
|
|
2475
2475
|
return SortReason;
|
|
2476
2476
|
}({});
|
|
2477
2477
|
|
|
2478
|
+
/**
|
|
2479
|
+
* do RTS transformation for 2D/3D
|
|
2480
|
+
*/
|
|
2481
|
+
|
|
2482
|
+
/** shared objects */
|
|
2483
|
+
var $vec3$2 = glMatrix.vec3.create();
|
|
2484
|
+
/** shared objects */
|
|
2485
|
+
var $mat4$1 = glMatrix.mat4.create();
|
|
2486
|
+
/** shared objects */
|
|
2487
|
+
var $quat$2 = glMatrix.quat.create();
|
|
2488
|
+
function updateLocalTransform(transform) {
|
|
2489
|
+
if (!transform.localDirtyFlag) {
|
|
2490
|
+
return;
|
|
2491
|
+
}
|
|
2492
|
+
var hasSkew = transform.localSkew[0] !== 0 || transform.localSkew[1] !== 0;
|
|
2493
|
+
if (hasSkew) {
|
|
2494
|
+
glMatrix.mat4.fromRotationTranslationScaleOrigin(transform.localTransform, transform.localRotation, transform.localPosition, glMatrix.vec3.fromValues(1, 1, 1), transform.origin);
|
|
2495
|
+
|
|
2496
|
+
// apply skew2D
|
|
2497
|
+
if (transform.localSkew[0] !== 0 || transform.localSkew[1] !== 0) {
|
|
2498
|
+
glMatrix.mat4.identity($mat4$1);
|
|
2499
|
+
$mat4$1[4] = Math.tan(transform.localSkew[0]);
|
|
2500
|
+
$mat4$1[1] = Math.tan(transform.localSkew[1]);
|
|
2501
|
+
glMatrix.mat4.multiply(transform.localTransform, transform.localTransform, $mat4$1);
|
|
2502
|
+
}
|
|
2503
|
+
var scaling = glMatrix.mat4.fromRotationTranslationScaleOrigin($mat4$1, glMatrix.quat.set($quat$2, 0, 0, 0, 1), glMatrix.vec3.set($vec3$2, 1, 1, 1), transform.localScale, transform.origin);
|
|
2504
|
+
glMatrix.mat4.multiply(transform.localTransform, transform.localTransform, scaling);
|
|
2505
|
+
} else {
|
|
2506
|
+
var localTransform = transform.localTransform,
|
|
2507
|
+
localPosition = transform.localPosition,
|
|
2508
|
+
localRotation = transform.localRotation,
|
|
2509
|
+
localScale = transform.localScale,
|
|
2510
|
+
origin = transform.origin;
|
|
2511
|
+
var hasPosition = localPosition[0] !== 0 || localPosition[1] !== 0 || localPosition[2] !== 0;
|
|
2512
|
+
var hasRotation = localRotation[3] !== 1 || localRotation[0] !== 0 || localRotation[1] !== 0 || localRotation[2] !== 0;
|
|
2513
|
+
var hasScale = localScale[0] !== 1 || localScale[1] !== 1 || localScale[2] !== 1;
|
|
2514
|
+
var hasOrigin = origin[0] !== 0 || origin[1] !== 0 || origin[2] !== 0;
|
|
2515
|
+
if (!hasRotation && !hasScale && !hasOrigin) {
|
|
2516
|
+
if (hasPosition) {
|
|
2517
|
+
glMatrix.mat4.fromTranslation(localTransform, localPosition);
|
|
2518
|
+
} else {
|
|
2519
|
+
glMatrix.mat4.identity(localTransform);
|
|
2520
|
+
}
|
|
2521
|
+
} else {
|
|
2522
|
+
// @see https://github.com/mattdesl/css-mat4/blob/master/index.js
|
|
2523
|
+
glMatrix.mat4.fromRotationTranslationScaleOrigin(localTransform, localRotation, localPosition, localScale, origin);
|
|
2524
|
+
}
|
|
2525
|
+
}
|
|
2526
|
+
transform.localDirtyFlag = false;
|
|
2527
|
+
}
|
|
2528
|
+
function updateWorldTransform(transform, parentTransform) {
|
|
2529
|
+
if (!transform.dirtyFlag) {
|
|
2530
|
+
return;
|
|
2531
|
+
}
|
|
2532
|
+
if (!parentTransform) {
|
|
2533
|
+
glMatrix.mat4.copy(transform.worldTransform, transform.localTransform);
|
|
2534
|
+
} else {
|
|
2535
|
+
// TODO: should we support scale compensation?
|
|
2536
|
+
// @see https://github.com/playcanvas/engine/issues/1077#issuecomment-359765557
|
|
2537
|
+
glMatrix.mat4.multiply(transform.worldTransform, parentTransform.worldTransform, transform.localTransform);
|
|
2538
|
+
}
|
|
2539
|
+
transform.dirtyFlag = false;
|
|
2540
|
+
}
|
|
2541
|
+
|
|
2478
2542
|
var EMPTY_PARSED_PATH = {
|
|
2479
2543
|
absolutePath: [],
|
|
2480
2544
|
hasArc: false,
|
|
@@ -7020,10 +7084,9 @@ var DefaultStyleValueRegistry = /*#__PURE__*/function () {
|
|
|
7020
7084
|
}
|
|
7021
7085
|
if (needUpdateGeometry) {
|
|
7022
7086
|
object.geometry.dirty = true;
|
|
7023
|
-
object.
|
|
7024
|
-
object.renderable.renderBoundsDirty = true;
|
|
7087
|
+
object.dirty(true, true);
|
|
7025
7088
|
if (!options.forceUpdateGeometry) {
|
|
7026
|
-
this.runtime.sceneGraphService.
|
|
7089
|
+
this.runtime.sceneGraphService.dirtyToRoot(object);
|
|
7027
7090
|
}
|
|
7028
7091
|
}
|
|
7029
7092
|
}
|
|
@@ -7218,7 +7281,7 @@ var CSSPropertyClipPath = /*#__PURE__*/function () {
|
|
|
7218
7281
|
// should affect children
|
|
7219
7282
|
object.forEach(function (leaf) {
|
|
7220
7283
|
if (leaf.childNodes.length === 0) {
|
|
7221
|
-
runtime.sceneGraphService.
|
|
7284
|
+
runtime.sceneGraphService.dirtyToRoot(leaf);
|
|
7222
7285
|
}
|
|
7223
7286
|
});
|
|
7224
7287
|
}
|
|
@@ -7819,38 +7882,38 @@ var AsyncSeriesWaterfallHook = /*#__PURE__*/function () {
|
|
|
7819
7882
|
i,
|
|
7820
7883
|
callback,
|
|
7821
7884
|
_args = arguments;
|
|
7822
|
-
return _regeneratorRuntime().wrap(function
|
|
7885
|
+
return _regeneratorRuntime().wrap(function (_context) {
|
|
7823
7886
|
while (1) switch (_context.prev = _context.next) {
|
|
7824
7887
|
case 0:
|
|
7825
7888
|
if (!this.callbacks.length) {
|
|
7826
|
-
_context.next =
|
|
7889
|
+
_context.next = 6;
|
|
7827
7890
|
break;
|
|
7828
7891
|
}
|
|
7829
|
-
_context.next =
|
|
7892
|
+
_context.next = 1;
|
|
7830
7893
|
return (_this$callbacks = this.callbacks)[0].apply(_this$callbacks, _args);
|
|
7831
|
-
case
|
|
7894
|
+
case 1:
|
|
7832
7895
|
result = _context.sent;
|
|
7833
7896
|
i = 0;
|
|
7834
|
-
case
|
|
7897
|
+
case 2:
|
|
7835
7898
|
if (!(i < this.callbacks.length - 1)) {
|
|
7836
|
-
_context.next =
|
|
7899
|
+
_context.next = 5;
|
|
7837
7900
|
break;
|
|
7838
7901
|
}
|
|
7839
7902
|
callback = this.callbacks[i]; // @ts-ignore
|
|
7840
7903
|
// eslint-disable-next-line no-await-in-loop
|
|
7841
|
-
_context.next =
|
|
7904
|
+
_context.next = 3;
|
|
7842
7905
|
return callback(result);
|
|
7843
|
-
case
|
|
7906
|
+
case 3:
|
|
7844
7907
|
result = _context.sent;
|
|
7845
|
-
case
|
|
7908
|
+
case 4:
|
|
7846
7909
|
i++;
|
|
7847
|
-
_context.next =
|
|
7910
|
+
_context.next = 2;
|
|
7848
7911
|
break;
|
|
7849
|
-
case
|
|
7912
|
+
case 5:
|
|
7850
7913
|
return _context.abrupt("return", result);
|
|
7851
|
-
case
|
|
7914
|
+
case 6:
|
|
7852
7915
|
return _context.abrupt("return", null);
|
|
7853
|
-
case
|
|
7916
|
+
case 7:
|
|
7854
7917
|
case "end":
|
|
7855
7918
|
return _context.stop();
|
|
7856
7919
|
}
|
|
@@ -8040,7 +8103,7 @@ var optimizer = {
|
|
|
8040
8103
|
runtime.sceneGraphService.setLocalScale(object, $vec3One$1, false);
|
|
8041
8104
|
runtime.sceneGraphService.setLocalEulerAngles(object, $vec3Zero$1, undefined, undefined, false);
|
|
8042
8105
|
runtime.sceneGraphService.setLocalPosition(object, [d[0].value, d[1].value, 0], false);
|
|
8043
|
-
runtime.sceneGraphService.
|
|
8106
|
+
runtime.sceneGraphService.dirtyLocalTransform(object, object.transformable);
|
|
8044
8107
|
}
|
|
8045
8108
|
};
|
|
8046
8109
|
function parsedTransformToMat4(transform, object) {
|
|
@@ -8160,7 +8223,7 @@ var CSSPropertyZIndex = /*#__PURE__*/function () {
|
|
|
8160
8223
|
var parentRenderable = parentEntity.renderable;
|
|
8161
8224
|
var parentSortable = parentEntity.sortable;
|
|
8162
8225
|
if (parentRenderable) {
|
|
8163
|
-
|
|
8226
|
+
parentEntity.dirty();
|
|
8164
8227
|
}
|
|
8165
8228
|
// need re-sort on parent
|
|
8166
8229
|
if (parentSortable) {
|
|
@@ -8980,8 +9043,6 @@ var CustomEvent = /*#__PURE__*/function (_FederatedEvent) {
|
|
|
8980
9043
|
return _createClass(CustomEvent);
|
|
8981
9044
|
}(FederatedEvent);
|
|
8982
9045
|
|
|
8983
|
-
var CANVAS_CACHE = new WeakMap();
|
|
8984
|
-
|
|
8985
9046
|
/**
|
|
8986
9047
|
* Objects that can receive events and may have listeners for them.
|
|
8987
9048
|
* eg. Element, Canvas, DisplayObject
|
|
@@ -9071,35 +9132,49 @@ var EventTarget = /*#__PURE__*/function () {
|
|
|
9071
9132
|
value: function emit(eventName, object) {
|
|
9072
9133
|
this.dispatchEvent(new CustomEvent(eventName, object));
|
|
9073
9134
|
}
|
|
9074
|
-
|
|
9075
|
-
|
|
9076
|
-
|
|
9135
|
+
}, {
|
|
9136
|
+
key: "dispatchEventToSelf",
|
|
9137
|
+
value: function dispatchEventToSelf(e) {
|
|
9138
|
+
e.target || (e.target = this);
|
|
9139
|
+
e.currentTarget = this;
|
|
9140
|
+
this.emitter.emit(e.type, e);
|
|
9141
|
+
}
|
|
9077
9142
|
}, {
|
|
9078
9143
|
key: "dispatchEvent",
|
|
9079
9144
|
value: function dispatchEvent(e) {
|
|
9080
9145
|
var skipPropagate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
9081
|
-
var
|
|
9082
|
-
if (
|
|
9146
|
+
var dispatchToSelf = arguments.length > 2 ? arguments[2] : undefined;
|
|
9147
|
+
if (dispatchToSelf) {
|
|
9148
|
+
this.dispatchEventToSelf(e);
|
|
9149
|
+
return true;
|
|
9150
|
+
}
|
|
9151
|
+
var canvas;
|
|
9152
|
+
if (this.document) {
|
|
9153
|
+
canvas = this;
|
|
9154
|
+
} else if (this.defaultView) {
|
|
9155
|
+
canvas = this.defaultView;
|
|
9156
|
+
} else {
|
|
9083
9157
|
var _ownerDocument;
|
|
9084
|
-
|
|
9085
|
-
if (this.document) canvas = this;
|
|
9086
|
-
// @ts-expect-error defaultView may be defined in inherited class
|
|
9087
|
-
else if (this.defaultView) canvas = this.defaultView;else canvas = (_ownerDocument = this.ownerDocument) === null || _ownerDocument === void 0 ? void 0 : _ownerDocument.defaultView;
|
|
9088
|
-
if (canvas) CANVAS_CACHE.set(this, canvas);
|
|
9158
|
+
canvas = (_ownerDocument = this.ownerDocument) === null || _ownerDocument === void 0 ? void 0 : _ownerDocument.defaultView;
|
|
9089
9159
|
}
|
|
9090
9160
|
if (canvas) {
|
|
9091
9161
|
e.manager = canvas.getEventService();
|
|
9092
9162
|
if (!e.manager) return false;
|
|
9093
9163
|
e.defaultPrevented = false;
|
|
9094
|
-
if (e.path)
|
|
9095
|
-
|
|
9096
|
-
else
|
|
9097
|
-
|
|
9164
|
+
if (e.path) {
|
|
9165
|
+
e.path.length = 0;
|
|
9166
|
+
} else {
|
|
9167
|
+
// @ts-ignore
|
|
9168
|
+
e.page = [];
|
|
9169
|
+
}
|
|
9170
|
+
if (!skipPropagate) {
|
|
9171
|
+
e.target = this;
|
|
9172
|
+
}
|
|
9098
9173
|
e.manager.dispatchEvent(e, e.type, skipPropagate);
|
|
9099
9174
|
} else {
|
|
9100
9175
|
// HACK Fixed the issue that after an element leaves the DOM tree, there is no associated canvas,
|
|
9101
9176
|
// which causes the removed and destroy events to not be triggered
|
|
9102
|
-
this.
|
|
9177
|
+
this.dispatchEventToSelf(e);
|
|
9103
9178
|
}
|
|
9104
9179
|
return !e.defaultPrevented;
|
|
9105
9180
|
}
|
|
@@ -9157,6 +9232,7 @@ var Node = /*#__PURE__*/function (_EventTarget) {
|
|
|
9157
9232
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/ParentNode
|
|
9158
9233
|
*/
|
|
9159
9234
|
_this.parentNode = null;
|
|
9235
|
+
_this.destroyed = false;
|
|
9160
9236
|
return _this;
|
|
9161
9237
|
}
|
|
9162
9238
|
_inherits(Node, _EventTarget);
|
|
@@ -10401,6 +10477,9 @@ var RenderingService = /*#__PURE__*/function () {
|
|
|
10401
10477
|
* called after every dirty object get rendered
|
|
10402
10478
|
*/
|
|
10403
10479
|
afterRender: new SyncHook(),
|
|
10480
|
+
/**
|
|
10481
|
+
* commit - draw the result on the canvas
|
|
10482
|
+
*/
|
|
10404
10483
|
endFrame: new SyncHook(),
|
|
10405
10484
|
destroy: new SyncHook(),
|
|
10406
10485
|
/**
|
|
@@ -10469,7 +10548,6 @@ var RenderingService = /*#__PURE__*/function () {
|
|
|
10469
10548
|
}, {
|
|
10470
10549
|
key: "render",
|
|
10471
10550
|
value: function render(canvasConfig, frame, rerenderCallback) {
|
|
10472
|
-
var _this2 = this;
|
|
10473
10551
|
this.stats.total = 0;
|
|
10474
10552
|
this.stats.rendered = 0;
|
|
10475
10553
|
this.zIndexCounter = 0;
|
|
@@ -10480,20 +10558,12 @@ var RenderingService = /*#__PURE__*/function () {
|
|
|
10480
10558
|
// @ts-ignore
|
|
10481
10559
|
renderingContext.dirtyRectangleRenderingDisabled = this.disableDirtyRectangleRendering();
|
|
10482
10560
|
var onlyCameraChanged = renderingContext.renderReasons.size === 1 && renderingContext.renderReasons.has(RenderReason.CAMERA_CHANGED);
|
|
10483
|
-
var shouldTriggerRenderHooks = !canvasConfig.disableRenderHooks || !
|
|
10484
|
-
if (shouldTriggerRenderHooks) {
|
|
10485
|
-
this.renderDisplayObject(renderingContext.root, canvasConfig, renderingContext);
|
|
10486
|
-
}
|
|
10561
|
+
var shouldTriggerRenderHooks = !canvasConfig.disableRenderHooks || !onlyCameraChanged;
|
|
10487
10562
|
this.hooks.beginFrame.call(frame);
|
|
10488
10563
|
if (shouldTriggerRenderHooks) {
|
|
10489
|
-
renderingContext.
|
|
10490
|
-
_this2.hooks.beforeRender.call(object);
|
|
10491
|
-
_this2.hooks.render.call(object);
|
|
10492
|
-
_this2.hooks.afterRender.call(object);
|
|
10493
|
-
});
|
|
10564
|
+
this.renderDisplayObject(renderingContext.root, canvasConfig, renderingContext);
|
|
10494
10565
|
}
|
|
10495
10566
|
this.hooks.endFrame.call(frame);
|
|
10496
|
-
renderingContext.renderListCurrentFrame = [];
|
|
10497
10567
|
renderingContext.renderReasons.clear();
|
|
10498
10568
|
rerenderCallback();
|
|
10499
10569
|
}
|
|
@@ -10517,14 +10587,14 @@ var RenderingService = /*#__PURE__*/function () {
|
|
|
10517
10587
|
var objectChanged = enableDirtyCheck ?
|
|
10518
10588
|
// @ts-ignore
|
|
10519
10589
|
renderable.dirty || renderingContext.dirtyRectangleRenderingDisabled ? object : null : object;
|
|
10590
|
+
var objectToRender = null;
|
|
10520
10591
|
if (objectChanged) {
|
|
10521
|
-
|
|
10592
|
+
objectToRender = enableCulling ? self.hooks.cull.call(objectChanged, self.context.camera) : objectChanged;
|
|
10522
10593
|
if (objectToRender) {
|
|
10523
10594
|
self.stats.rendered += 1;
|
|
10524
|
-
renderingContext.renderListCurrentFrame.push(objectToRender);
|
|
10525
10595
|
}
|
|
10526
10596
|
}
|
|
10527
|
-
|
|
10597
|
+
object.dirty(false);
|
|
10528
10598
|
sortable.renderOrder = self.zIndexCounter;
|
|
10529
10599
|
self.zIndexCounter += 1;
|
|
10530
10600
|
self.stats.total += 1;
|
|
@@ -10536,6 +10606,13 @@ var RenderingService = /*#__PURE__*/function () {
|
|
|
10536
10606
|
sortable.dirtyChildren = [];
|
|
10537
10607
|
sortable.dirtyReason = undefined;
|
|
10538
10608
|
}
|
|
10609
|
+
|
|
10610
|
+
// trigger render hooks
|
|
10611
|
+
if (objectToRender) {
|
|
10612
|
+
self.hooks.beforeRender.call(objectToRender);
|
|
10613
|
+
self.hooks.render.call(objectToRender);
|
|
10614
|
+
self.hooks.afterRender.call(objectToRender);
|
|
10615
|
+
}
|
|
10539
10616
|
}
|
|
10540
10617
|
var stack = [displayObject];
|
|
10541
10618
|
while (stack.length > 0) {
|
|
@@ -10816,13 +10893,6 @@ MutationEvent.ADDITION = 2;
|
|
|
10816
10893
|
MutationEvent.MODIFICATION = 1;
|
|
10817
10894
|
MutationEvent.REMOVAL = 3;
|
|
10818
10895
|
|
|
10819
|
-
function markRenderableDirty(e) {
|
|
10820
|
-
var renderable = e.renderable;
|
|
10821
|
-
if (renderable) {
|
|
10822
|
-
renderable.renderBoundsDirty = true;
|
|
10823
|
-
renderable.boundsDirty = true;
|
|
10824
|
-
}
|
|
10825
|
-
}
|
|
10826
10896
|
var reparentEvent = new MutationEvent(ElementEvent.REPARENT, null, '', '', '', 0, '', '');
|
|
10827
10897
|
|
|
10828
10898
|
// Object pooling
|
|
@@ -10924,14 +10994,18 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
10924
10994
|
sortable.dirtyReason = SortReason.ADDED;
|
|
10925
10995
|
}
|
|
10926
10996
|
if (isAttachToFragment) return;
|
|
10927
|
-
if (isChildFragment)
|
|
10997
|
+
if (isChildFragment) {
|
|
10998
|
+
this.dirtifyFragment(child);
|
|
10999
|
+
} else {
|
|
10928
11000
|
var transform = child.transformable;
|
|
10929
11001
|
if (transform) {
|
|
10930
|
-
this.
|
|
11002
|
+
this.dirtyWorldTransform(child, transform);
|
|
10931
11003
|
}
|
|
10932
11004
|
}
|
|
10933
11005
|
if (detached) {
|
|
10934
|
-
|
|
11006
|
+
var _parent$ownerDocument;
|
|
11007
|
+
var enableCancelEventPropagation = ((_parent$ownerDocument = parent.ownerDocument) === null || _parent$ownerDocument === void 0 || (_parent$ownerDocument = _parent$ownerDocument.defaultView) === null || _parent$ownerDocument === void 0 || (_parent$ownerDocument = _parent$ownerDocument.getConfig()) === null || _parent$ownerDocument === void 0 || (_parent$ownerDocument = _parent$ownerDocument.future) === null || _parent$ownerDocument === void 0 ? void 0 : _parent$ownerDocument.experimentalCancelEventPropagation) === true;
|
|
11008
|
+
child.dispatchEvent(reparentEvent, enableCancelEventPropagation, enableCancelEventPropagation);
|
|
10935
11009
|
}
|
|
10936
11010
|
}
|
|
10937
11011
|
}, {
|
|
@@ -10966,71 +11040,95 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
10966
11040
|
child.parentNode.childNodes.splice(index, 1);
|
|
10967
11041
|
}
|
|
10968
11042
|
if (transform) {
|
|
10969
|
-
this.
|
|
11043
|
+
this.dirtyWorldTransform(child, transform);
|
|
10970
11044
|
}
|
|
10971
11045
|
child.parentNode = null;
|
|
10972
11046
|
}
|
|
11047
|
+
|
|
11048
|
+
// #region local-transform ----------------------------------------------------------------
|
|
10973
11049
|
}, {
|
|
10974
|
-
key: "
|
|
10975
|
-
value: function
|
|
10976
|
-
element.
|
|
10977
|
-
|
|
11050
|
+
key: "getLocalPosition",
|
|
11051
|
+
value: function getLocalPosition(element) {
|
|
11052
|
+
return element.transformable.localPosition;
|
|
11053
|
+
}
|
|
11054
|
+
}, {
|
|
11055
|
+
key: "getLocalRotation",
|
|
11056
|
+
value: function getLocalRotation(element) {
|
|
11057
|
+
return element.transformable.localRotation;
|
|
11058
|
+
}
|
|
11059
|
+
}, {
|
|
11060
|
+
key: "getLocalScale",
|
|
11061
|
+
value: function getLocalScale(element) {
|
|
11062
|
+
return element.transformable.localScale;
|
|
11063
|
+
}
|
|
11064
|
+
}, {
|
|
11065
|
+
key: "getLocalSkew",
|
|
11066
|
+
value: function getLocalSkew(element) {
|
|
11067
|
+
return element.transformable.localSkew;
|
|
11068
|
+
}
|
|
11069
|
+
}, {
|
|
11070
|
+
key: "getLocalTransform",
|
|
11071
|
+
value: function getLocalTransform(element) {
|
|
11072
|
+
var transform = element.transformable;
|
|
11073
|
+
updateLocalTransform(transform);
|
|
11074
|
+
return transform.localTransform;
|
|
10978
11075
|
}
|
|
10979
11076
|
|
|
10980
11077
|
/**
|
|
10981
|
-
*
|
|
10982
|
-
*
|
|
10983
|
-
* @see https://stackoverflow.com/questions/40748452/how-to-change-css-transform-origin-but-preserve-transformation
|
|
11078
|
+
* move to position in local space
|
|
10984
11079
|
*/
|
|
10985
11080
|
}, {
|
|
10986
|
-
key: "
|
|
10987
|
-
value: function
|
|
10988
|
-
var
|
|
10989
|
-
var
|
|
10990
|
-
if (typeof origin === 'number') {
|
|
10991
|
-
origin = [origin, y, z];
|
|
10992
|
-
}
|
|
11081
|
+
key: "setLocalPosition",
|
|
11082
|
+
value: function setLocalPosition(element, position) {
|
|
11083
|
+
var _position$;
|
|
11084
|
+
var dirtify = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
10993
11085
|
var transform = element.transformable;
|
|
10994
|
-
|
|
11086
|
+
$setLocalPosition[0] = position[0];
|
|
11087
|
+
$setLocalPosition[1] = position[1];
|
|
11088
|
+
$setLocalPosition[2] = (_position$ = position[2]) !== null && _position$ !== void 0 ? _position$ : 0;
|
|
11089
|
+
if (glMatrix.vec3.equals(transform.localPosition, $setLocalPosition)) {
|
|
10995
11090
|
return;
|
|
10996
11091
|
}
|
|
10997
|
-
|
|
10998
|
-
|
|
10999
|
-
|
|
11000
|
-
|
|
11001
|
-
|
|
11002
|
-
// update origin
|
|
11003
|
-
originVec[0] = origin[0];
|
|
11004
|
-
originVec[1] = origin[1];
|
|
11005
|
-
originVec[2] = origin[2] || 0;
|
|
11006
|
-
this.dirtifyLocal(element, transform);
|
|
11092
|
+
glMatrix.vec3.copy(transform.localPosition, $setLocalPosition);
|
|
11093
|
+
if (dirtify) {
|
|
11094
|
+
this.dirtyLocalTransform(element, transform);
|
|
11095
|
+
}
|
|
11007
11096
|
}
|
|
11008
11097
|
|
|
11009
11098
|
/**
|
|
11010
|
-
*
|
|
11099
|
+
* translate in local space
|
|
11100
|
+
*
|
|
11101
|
+
* @example
|
|
11102
|
+
* ```
|
|
11103
|
+
* translateLocal(x, y, z)
|
|
11104
|
+
* translateLocal(vec3(x, y, z))
|
|
11105
|
+
* ```
|
|
11011
11106
|
*/
|
|
11012
11107
|
}, {
|
|
11013
|
-
key: "
|
|
11014
|
-
value: function
|
|
11108
|
+
key: "translateLocal",
|
|
11109
|
+
value: function translateLocal(element, translation) {
|
|
11015
11110
|
var y = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
11016
11111
|
var z = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
11017
|
-
if (typeof
|
|
11018
|
-
|
|
11112
|
+
if (typeof translation === 'number') {
|
|
11113
|
+
translation = glMatrix.vec3.fromValues(translation, y, z);
|
|
11019
11114
|
}
|
|
11020
11115
|
var transform = element.transformable;
|
|
11021
|
-
if (
|
|
11022
|
-
|
|
11023
|
-
|
|
11024
|
-
|
|
11025
|
-
|
|
11026
|
-
|
|
11027
|
-
|
|
11028
|
-
|
|
11029
|
-
|
|
11030
|
-
|
|
11031
|
-
glMatrix.quat.
|
|
11032
|
-
|
|
11033
|
-
|
|
11116
|
+
if (glMatrix.vec3.equals(translation, $vec3Zero)) return;
|
|
11117
|
+
glMatrix.vec3.transformQuat(translation, translation, transform.localRotation);
|
|
11118
|
+
glMatrix.vec3.add(transform.localPosition, transform.localPosition, translation);
|
|
11119
|
+
this.dirtyLocalTransform(element, transform);
|
|
11120
|
+
}
|
|
11121
|
+
}, {
|
|
11122
|
+
key: "setLocalRotation",
|
|
11123
|
+
value: function setLocalRotation(element, rotation, y, z, w) {
|
|
11124
|
+
var dirtify = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true;
|
|
11125
|
+
if (typeof rotation === 'number') {
|
|
11126
|
+
rotation = glMatrix.quat.set($quat$1, rotation, y, z, w);
|
|
11127
|
+
}
|
|
11128
|
+
var transform = element.transformable;
|
|
11129
|
+
glMatrix.quat.copy(transform.localRotation, rotation);
|
|
11130
|
+
if (dirtify) {
|
|
11131
|
+
this.dirtyLocalTransform(element, transform);
|
|
11034
11132
|
}
|
|
11035
11133
|
}
|
|
11036
11134
|
|
|
@@ -11049,29 +11147,46 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
11049
11147
|
var transform = element.transformable;
|
|
11050
11148
|
glMatrix.quat.fromEuler($rotateLocal, degrees[0], degrees[1], degrees[2]);
|
|
11051
11149
|
glMatrix.quat.mul(transform.localRotation, transform.localRotation, $rotateLocal);
|
|
11052
|
-
this.
|
|
11150
|
+
this.dirtyLocalTransform(element, transform);
|
|
11151
|
+
}
|
|
11152
|
+
}, {
|
|
11153
|
+
key: "setLocalScale",
|
|
11154
|
+
value: function setLocalScale(element, scaling) {
|
|
11155
|
+
var _scaling$;
|
|
11156
|
+
var dirtify = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
11157
|
+
var transform = element.transformable;
|
|
11158
|
+
glMatrix.vec3.set($vec3$1, scaling[0], scaling[1], (_scaling$ = scaling[2]) !== null && _scaling$ !== void 0 ? _scaling$ : transform.localScale[2]);
|
|
11159
|
+
if (glMatrix.vec3.equals($vec3$1, transform.localScale)) {
|
|
11160
|
+
return;
|
|
11161
|
+
}
|
|
11162
|
+
glMatrix.vec3.copy(transform.localScale, $vec3$1);
|
|
11163
|
+
if (dirtify) {
|
|
11164
|
+
this.dirtyLocalTransform(element, transform);
|
|
11165
|
+
}
|
|
11053
11166
|
}
|
|
11054
11167
|
|
|
11055
11168
|
/**
|
|
11056
|
-
*
|
|
11169
|
+
* scale in local space
|
|
11057
11170
|
*/
|
|
11058
11171
|
}, {
|
|
11059
|
-
key: "
|
|
11060
|
-
value: function
|
|
11061
|
-
var
|
|
11062
|
-
var
|
|
11063
|
-
|
|
11064
|
-
|
|
11172
|
+
key: "scaleLocal",
|
|
11173
|
+
value: function scaleLocal(element, scaling) {
|
|
11174
|
+
var _scaling$2;
|
|
11175
|
+
var transform = element.transformable;
|
|
11176
|
+
glMatrix.vec3.multiply(transform.localScale, transform.localScale, glMatrix.vec3.set($vec3$1, scaling[0], scaling[1], (_scaling$2 = scaling[2]) !== null && _scaling$2 !== void 0 ? _scaling$2 : 1));
|
|
11177
|
+
this.dirtyLocalTransform(element, transform);
|
|
11178
|
+
}
|
|
11179
|
+
}, {
|
|
11180
|
+
key: "setLocalSkew",
|
|
11181
|
+
value: function setLocalSkew(element, skew, y) {
|
|
11182
|
+
var dirtify = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
|
|
11183
|
+
if (typeof skew === 'number') {
|
|
11184
|
+
skew = glMatrix.vec2.set($vec2, skew, y);
|
|
11065
11185
|
}
|
|
11066
11186
|
var transform = element.transformable;
|
|
11067
|
-
|
|
11068
|
-
|
|
11069
|
-
|
|
11070
|
-
glMatrix.quat.fromEuler(transform.localRotation, degrees[0], degrees[1], degrees[2]);
|
|
11071
|
-
var parentRotation = this.getRotation(element.parentNode);
|
|
11072
|
-
glMatrix.quat.copy($setEulerAngles_InvParentRot, glMatrix.quat.invert($quat$1, parentRotation));
|
|
11073
|
-
glMatrix.quat.mul(transform.localRotation, transform.localRotation, $setEulerAngles_InvParentRot);
|
|
11074
|
-
this.dirtifyLocal(element, transform);
|
|
11187
|
+
glMatrix.vec2.copy(transform.localSkew, skew);
|
|
11188
|
+
if (dirtify) {
|
|
11189
|
+
this.dirtyLocalTransform(element, transform);
|
|
11075
11190
|
}
|
|
11076
11191
|
}
|
|
11077
11192
|
|
|
@@ -11090,109 +11205,97 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
11090
11205
|
var transform = element.transformable;
|
|
11091
11206
|
glMatrix.quat.fromEuler(transform.localRotation, degrees[0], degrees[1], degrees[2]);
|
|
11092
11207
|
if (dirtify) {
|
|
11093
|
-
this.
|
|
11208
|
+
this.dirtyLocalTransform(element, transform);
|
|
11094
11209
|
}
|
|
11095
11210
|
}
|
|
11211
|
+
}, {
|
|
11212
|
+
key: "setLocalTransform",
|
|
11213
|
+
value: function setLocalTransform(element, transform) {
|
|
11214
|
+
var t = glMatrix.mat4.getTranslation($setLocalTransform_1, transform);
|
|
11215
|
+
var r = glMatrix.mat4.getRotation($setLocalTransform_2, transform);
|
|
11216
|
+
var s = glMatrix.mat4.getScaling($setLocalTransform_3, transform);
|
|
11217
|
+
this.setLocalScale(element, s, false);
|
|
11218
|
+
this.setLocalPosition(element, t, false);
|
|
11219
|
+
this.setLocalRotation(element, r, undefined, undefined, undefined, false);
|
|
11220
|
+
this.dirtyLocalTransform(element, element.transformable);
|
|
11221
|
+
}
|
|
11222
|
+
}, {
|
|
11223
|
+
key: "resetLocalTransform",
|
|
11224
|
+
value: function resetLocalTransform(element) {
|
|
11225
|
+
this.setLocalScale(element, $vec3One, false);
|
|
11226
|
+
this.setLocalPosition(element, $vec3Zero, false);
|
|
11227
|
+
this.setLocalEulerAngles(element, $vec3Zero, undefined, undefined, false);
|
|
11228
|
+
this.setLocalSkew(element, $vec2Zero, undefined, false);
|
|
11229
|
+
this.dirtyLocalTransform(element, element.transformable);
|
|
11230
|
+
}
|
|
11096
11231
|
|
|
11097
|
-
|
|
11098
|
-
|
|
11099
|
-
*
|
|
11100
|
-
* @example
|
|
11101
|
-
* ```
|
|
11102
|
-
* translateLocal(x, y, z)
|
|
11103
|
-
* translateLocal(vec3(x, y, z))
|
|
11104
|
-
* ```
|
|
11105
|
-
*/
|
|
11232
|
+
// #endregion local-transform
|
|
11233
|
+
// #region transform ----------------------------------------------------------------
|
|
11106
11234
|
}, {
|
|
11107
|
-
key: "
|
|
11108
|
-
value: function
|
|
11109
|
-
var y = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
11110
|
-
var z = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
11111
|
-
if (typeof translation === 'number') {
|
|
11112
|
-
translation = glMatrix.vec3.fromValues(translation, y, z);
|
|
11113
|
-
}
|
|
11235
|
+
key: "getPosition",
|
|
11236
|
+
value: function getPosition(element) {
|
|
11114
11237
|
var transform = element.transformable;
|
|
11115
|
-
|
|
11116
|
-
glMatrix.vec3.transformQuat(translation, translation, transform.localRotation);
|
|
11117
|
-
glMatrix.vec3.add(transform.localPosition, transform.localPosition, translation);
|
|
11118
|
-
this.dirtifyLocal(element, transform);
|
|
11238
|
+
return glMatrix.mat4.getTranslation(transform.position, this.getWorldTransform(element, transform));
|
|
11119
11239
|
}
|
|
11120
|
-
|
|
11121
|
-
/**
|
|
11122
|
-
* move to position in world space
|
|
11123
|
-
*
|
|
11124
|
-
* 对应 g 原版的 move/moveTo
|
|
11125
|
-
* @see https://github.com/antvis/g/blob/master/packages/g-base/src/abstract/element.ts#L684-L689
|
|
11126
|
-
*/
|
|
11127
11240
|
}, {
|
|
11128
|
-
key: "
|
|
11129
|
-
value: function
|
|
11130
|
-
var _position$;
|
|
11241
|
+
key: "getRotation",
|
|
11242
|
+
value: function getRotation(element) {
|
|
11131
11243
|
var transform = element.transformable;
|
|
11132
|
-
|
|
11133
|
-
$setPosition_1[1] = position[1];
|
|
11134
|
-
$setPosition_1[2] = (_position$ = position[2]) !== null && _position$ !== void 0 ? _position$ : 0;
|
|
11135
|
-
if (glMatrix.vec3.equals(this.getPosition(element), $setPosition_1)) {
|
|
11136
|
-
return;
|
|
11137
|
-
}
|
|
11138
|
-
glMatrix.vec3.copy(transform.position, $setPosition_1);
|
|
11139
|
-
if (element.parentNode === null || !element.parentNode.transformable) {
|
|
11140
|
-
glMatrix.vec3.copy(transform.localPosition, $setPosition_1);
|
|
11141
|
-
} else {
|
|
11142
|
-
var parentTransform = element.parentNode.transformable;
|
|
11143
|
-
glMatrix.mat4.copy($setPosition_ParentInvertMatrix, parentTransform.worldTransform);
|
|
11144
|
-
glMatrix.mat4.invert($setPosition_ParentInvertMatrix, $setPosition_ParentInvertMatrix);
|
|
11145
|
-
glMatrix.vec3.transformMat4(transform.localPosition, $setPosition_1, $setPosition_ParentInvertMatrix);
|
|
11146
|
-
}
|
|
11147
|
-
this.dirtifyLocal(element, transform);
|
|
11244
|
+
return glMatrix.mat4.getRotation(transform.rotation, this.getWorldTransform(element, transform));
|
|
11148
11245
|
}
|
|
11149
|
-
|
|
11150
|
-
/**
|
|
11151
|
-
* move to position in local space
|
|
11152
|
-
*/
|
|
11153
11246
|
}, {
|
|
11154
|
-
key: "
|
|
11155
|
-
value: function
|
|
11156
|
-
var _position$2;
|
|
11157
|
-
var dirtify = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
11247
|
+
key: "getScale",
|
|
11248
|
+
value: function getScale(element) {
|
|
11158
11249
|
var transform = element.transformable;
|
|
11159
|
-
|
|
11160
|
-
|
|
11161
|
-
|
|
11162
|
-
|
|
11163
|
-
|
|
11250
|
+
return glMatrix.mat4.getScaling(transform.scaling, this.getWorldTransform(element, transform));
|
|
11251
|
+
}
|
|
11252
|
+
}, {
|
|
11253
|
+
key: "getOrigin",
|
|
11254
|
+
value: function getOrigin(element) {
|
|
11255
|
+
element.getGeometryBounds();
|
|
11256
|
+
return element.transformable.origin;
|
|
11257
|
+
}
|
|
11258
|
+
}, {
|
|
11259
|
+
key: "getWorldTransform",
|
|
11260
|
+
value: function getWorldTransform(element) {
|
|
11261
|
+
var transform = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : element.transformable;
|
|
11262
|
+
if (!transform.localDirtyFlag && !transform.dirtyFlag) {
|
|
11263
|
+
return transform.worldTransform;
|
|
11164
11264
|
}
|
|
11165
|
-
|
|
11166
|
-
|
|
11167
|
-
this.dirtifyLocal(element, transform);
|
|
11265
|
+
if (element.parentNode && element.parentNode.transformable) {
|
|
11266
|
+
this.getWorldTransform(element.parentNode);
|
|
11168
11267
|
}
|
|
11268
|
+
this.internalUpdateTransform(element);
|
|
11269
|
+
return transform.worldTransform;
|
|
11169
11270
|
}
|
|
11170
11271
|
|
|
11171
11272
|
/**
|
|
11172
|
-
*
|
|
11273
|
+
* move to position in world space
|
|
11274
|
+
*
|
|
11275
|
+
* 对应 g 原版的 move/moveTo
|
|
11276
|
+
* @see https://github.com/antvis/g/blob/master/packages/g-base/src/abstract/element.ts#L684-L689
|
|
11173
11277
|
*/
|
|
11174
11278
|
}, {
|
|
11175
|
-
key: "
|
|
11176
|
-
value: function
|
|
11177
|
-
var
|
|
11178
|
-
var transform = element.transformable;
|
|
11179
|
-
glMatrix.vec3.multiply(transform.localScale, transform.localScale, glMatrix.vec3.set($vec3$1, scaling[0], scaling[1], (_scaling$ = scaling[2]) !== null && _scaling$ !== void 0 ? _scaling$ : 1));
|
|
11180
|
-
this.dirtifyLocal(element, transform);
|
|
11181
|
-
}
|
|
11182
|
-
}, {
|
|
11183
|
-
key: "setLocalScale",
|
|
11184
|
-
value: function setLocalScale(element, scaling) {
|
|
11185
|
-
var _scaling$2;
|
|
11186
|
-
var dirtify = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
11279
|
+
key: "setPosition",
|
|
11280
|
+
value: function setPosition(element, position) {
|
|
11281
|
+
var _position$2;
|
|
11187
11282
|
var transform = element.transformable;
|
|
11188
|
-
|
|
11189
|
-
|
|
11283
|
+
$setPosition_1[0] = position[0];
|
|
11284
|
+
$setPosition_1[1] = position[1];
|
|
11285
|
+
$setPosition_1[2] = (_position$2 = position[2]) !== null && _position$2 !== void 0 ? _position$2 : 0;
|
|
11286
|
+
if (glMatrix.vec3.equals(this.getPosition(element), $setPosition_1)) {
|
|
11190
11287
|
return;
|
|
11191
11288
|
}
|
|
11192
|
-
glMatrix.vec3.copy(transform.
|
|
11193
|
-
if (
|
|
11194
|
-
|
|
11289
|
+
glMatrix.vec3.copy(transform.position, $setPosition_1);
|
|
11290
|
+
if (element.parentNode === null || !element.parentNode.transformable) {
|
|
11291
|
+
glMatrix.vec3.copy(transform.localPosition, $setPosition_1);
|
|
11292
|
+
} else {
|
|
11293
|
+
var parentTransform = element.parentNode.transformable;
|
|
11294
|
+
glMatrix.mat4.copy($setPosition_ParentInvertMatrix, parentTransform.worldTransform);
|
|
11295
|
+
glMatrix.mat4.invert($setPosition_ParentInvertMatrix, $setPosition_ParentInvertMatrix);
|
|
11296
|
+
glMatrix.vec3.transformMat4(transform.localPosition, $setPosition_1, $setPosition_ParentInvertMatrix);
|
|
11195
11297
|
}
|
|
11298
|
+
this.dirtyLocalTransform(element, transform);
|
|
11196
11299
|
}
|
|
11197
11300
|
|
|
11198
11301
|
/**
|
|
@@ -11234,299 +11337,92 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
11234
11337
|
glMatrix.quat.invert($quat$1, $quat$1);
|
|
11235
11338
|
glMatrix.quat.multiply(transform.localRotation, $quat$1, rotation);
|
|
11236
11339
|
glMatrix.quat.normalize(transform.localRotation, transform.localRotation);
|
|
11237
|
-
this.
|
|
11238
|
-
}
|
|
11239
|
-
}
|
|
11240
|
-
}, {
|
|
11241
|
-
key: "setLocalRotation",
|
|
11242
|
-
value: function setLocalRotation(element, rotation, y, z, w) {
|
|
11243
|
-
var dirtify = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true;
|
|
11244
|
-
if (typeof rotation === 'number') {
|
|
11245
|
-
rotation = glMatrix.quat.set($quat$1, rotation, y, z, w);
|
|
11246
|
-
}
|
|
11247
|
-
var transform = element.transformable;
|
|
11248
|
-
glMatrix.quat.copy(transform.localRotation, rotation);
|
|
11249
|
-
if (dirtify) {
|
|
11250
|
-
this.dirtifyLocal(element, transform);
|
|
11251
|
-
}
|
|
11252
|
-
}
|
|
11253
|
-
}, {
|
|
11254
|
-
key: "setLocalSkew",
|
|
11255
|
-
value: function setLocalSkew(element, skew, y) {
|
|
11256
|
-
var dirtify = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
|
|
11257
|
-
if (typeof skew === 'number') {
|
|
11258
|
-
skew = glMatrix.vec2.set($vec2, skew, y);
|
|
11259
|
-
}
|
|
11260
|
-
var transform = element.transformable;
|
|
11261
|
-
glMatrix.vec2.copy(transform.localSkew, skew);
|
|
11262
|
-
if (dirtify) {
|
|
11263
|
-
this.dirtifyLocal(element, transform);
|
|
11264
|
-
}
|
|
11265
|
-
}
|
|
11266
|
-
}, {
|
|
11267
|
-
key: "dirtifyLocal",
|
|
11268
|
-
value: function dirtifyLocal(element, transform) {
|
|
11269
|
-
if (isInFragment(element)) return;
|
|
11270
|
-
if (!transform.localDirtyFlag) {
|
|
11271
|
-
transform.localDirtyFlag = true;
|
|
11272
|
-
if (!transform.dirtyFlag) {
|
|
11273
|
-
this.dirtifyWorld(element, transform);
|
|
11274
|
-
}
|
|
11275
|
-
}
|
|
11276
|
-
}
|
|
11277
|
-
}, {
|
|
11278
|
-
key: "dirtifyWorld",
|
|
11279
|
-
value: function dirtifyWorld(element, transform) {
|
|
11280
|
-
if (!transform.dirtyFlag) {
|
|
11281
|
-
this.unfreezeParentToRoot(element);
|
|
11282
|
-
}
|
|
11283
|
-
this.dirtifyWorldInternal(element, transform);
|
|
11284
|
-
this.dirtifyToRoot(element, true);
|
|
11285
|
-
}
|
|
11286
|
-
}, {
|
|
11287
|
-
key: "dirtifyFragment",
|
|
11288
|
-
value: function dirtifyFragment(element) {
|
|
11289
|
-
var transform = element.transformable;
|
|
11290
|
-
if (transform) {
|
|
11291
|
-
transform.frozen = false;
|
|
11292
|
-
transform.dirtyFlag = true;
|
|
11293
|
-
transform.localDirtyFlag = true;
|
|
11294
|
-
}
|
|
11295
|
-
var renderable = element.renderable;
|
|
11296
|
-
if (renderable) {
|
|
11297
|
-
renderable.renderBoundsDirty = true;
|
|
11298
|
-
renderable.boundsDirty = true;
|
|
11299
|
-
renderable.dirty = true;
|
|
11300
|
-
}
|
|
11301
|
-
var length = element.childNodes.length;
|
|
11302
|
-
for (var i = 0; i < length; i++) {
|
|
11303
|
-
this.dirtifyFragment(element.childNodes[i]);
|
|
11304
|
-
}
|
|
11305
|
-
if (element.nodeName === Shape.FRAGMENT) {
|
|
11306
|
-
this.pendingEvents.set(element, false);
|
|
11340
|
+
this.dirtyLocalTransform(element, transform);
|
|
11307
11341
|
}
|
|
11308
11342
|
}
|
|
11309
|
-
}, {
|
|
11310
|
-
key: "triggerPendingEvents",
|
|
11311
|
-
value: function triggerPendingEvents() {
|
|
11312
|
-
var _this = this;
|
|
11313
|
-
var triggered = new Set();
|
|
11314
|
-
var trigger = function trigger(element, detail) {
|
|
11315
|
-
if (!element.isConnected || triggered.has(element) || element.nodeName === Shape.FRAGMENT) {
|
|
11316
|
-
return;
|
|
11317
|
-
}
|
|
11318
|
-
_this.boundsChangedEvent.detail = detail;
|
|
11319
|
-
_this.boundsChangedEvent.target = element;
|
|
11320
|
-
if (element.isMutationObserved) {
|
|
11321
|
-
element.dispatchEvent(_this.boundsChangedEvent);
|
|
11322
|
-
} else {
|
|
11323
|
-
element.ownerDocument.defaultView.dispatchEvent(_this.boundsChangedEvent, true);
|
|
11324
|
-
}
|
|
11325
|
-
triggered.add(element);
|
|
11326
|
-
};
|
|
11327
|
-
this.pendingEvents.forEach(function (affectChildren, element) {
|
|
11328
|
-
if (element.nodeName === Shape.FRAGMENT) {
|
|
11329
|
-
return;
|
|
11330
|
-
}
|
|
11331
|
-
$triggerPendingEvents_detail.affectChildren = affectChildren;
|
|
11332
|
-
if (affectChildren) {
|
|
11333
|
-
element.forEach(function (e) {
|
|
11334
|
-
trigger(e, $triggerPendingEvents_detail);
|
|
11335
|
-
});
|
|
11336
|
-
} else trigger(element, $triggerPendingEvents_detail);
|
|
11337
|
-
});
|
|
11338
|
-
triggered.clear();
|
|
11339
|
-
this.clearPendingEvents();
|
|
11340
|
-
}
|
|
11341
|
-
}, {
|
|
11342
|
-
key: "clearPendingEvents",
|
|
11343
|
-
value: function clearPendingEvents() {
|
|
11344
|
-
this.pendingEvents.clear();
|
|
11345
|
-
}
|
|
11346
|
-
}, {
|
|
11347
|
-
key: "dirtifyToRoot",
|
|
11348
|
-
value: function dirtifyToRoot(element) {
|
|
11349
|
-
var affectChildren = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
11350
|
-
var p = element;
|
|
11351
11343
|
|
|
11352
|
-
|
|
11353
|
-
|
|
11354
|
-
|
|
11355
|
-
}
|
|
11356
|
-
while (p) {
|
|
11357
|
-
markRenderableDirty(p);
|
|
11358
|
-
p = p.parentNode;
|
|
11359
|
-
}
|
|
11360
|
-
if (affectChildren) {
|
|
11361
|
-
element.forEach(function (e) {
|
|
11362
|
-
markRenderableDirty(e);
|
|
11363
|
-
});
|
|
11364
|
-
}
|
|
11365
|
-
this.informDependentDisplayObjects(element);
|
|
11366
|
-
this.pendingEvents.set(element, affectChildren);
|
|
11367
|
-
}
|
|
11368
|
-
}, {
|
|
11369
|
-
key: "updateDisplayObjectDependency",
|
|
11370
|
-
value: function updateDisplayObjectDependency(name, oldPath, newPath, object) {
|
|
11371
|
-
// clear ref to old clip path
|
|
11372
|
-
if (oldPath && oldPath !== newPath) {
|
|
11373
|
-
var oldDependencyMap = this.displayObjectDependencyMap.get(oldPath);
|
|
11374
|
-
if (oldDependencyMap && oldDependencyMap[name]) {
|
|
11375
|
-
var index = oldDependencyMap[name].indexOf(object);
|
|
11376
|
-
oldDependencyMap[name].splice(index, 1);
|
|
11377
|
-
}
|
|
11378
|
-
}
|
|
11379
|
-
if (newPath) {
|
|
11380
|
-
var newDependencyMap = this.displayObjectDependencyMap.get(newPath);
|
|
11381
|
-
if (!newDependencyMap) {
|
|
11382
|
-
this.displayObjectDependencyMap.set(newPath, {});
|
|
11383
|
-
newDependencyMap = this.displayObjectDependencyMap.get(newPath);
|
|
11384
|
-
}
|
|
11385
|
-
if (!newDependencyMap[name]) {
|
|
11386
|
-
newDependencyMap[name] = [];
|
|
11387
|
-
}
|
|
11388
|
-
newDependencyMap[name].push(object);
|
|
11389
|
-
}
|
|
11390
|
-
}
|
|
11344
|
+
/**
|
|
11345
|
+
* rotate in world space
|
|
11346
|
+
*/
|
|
11391
11347
|
}, {
|
|
11392
|
-
key: "
|
|
11393
|
-
value: function
|
|
11394
|
-
var
|
|
11395
|
-
var
|
|
11396
|
-
if (
|
|
11397
|
-
|
|
11348
|
+
key: "rotate",
|
|
11349
|
+
value: function rotate(element, degrees) {
|
|
11350
|
+
var y = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
11351
|
+
var z = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
11352
|
+
if (typeof degrees === 'number') {
|
|
11353
|
+
degrees = glMatrix.vec3.fromValues(degrees, y, z);
|
|
11398
11354
|
}
|
|
11399
|
-
Object.keys(dependencyMap).forEach(function (name) {
|
|
11400
|
-
dependencyMap[name].forEach(function (target) {
|
|
11401
|
-
_this2.dirtifyToRoot(target, true);
|
|
11402
|
-
target.dispatchEvent(new MutationEvent(ElementEvent.ATTR_MODIFIED, target, _this2, _this2, name, MutationEvent.MODIFICATION, _this2, _this2));
|
|
11403
|
-
if (target.isCustomElement && target.isConnected) {
|
|
11404
|
-
if (target.attributeChangedCallback) {
|
|
11405
|
-
target.attributeChangedCallback(name, _this2, _this2);
|
|
11406
|
-
}
|
|
11407
|
-
}
|
|
11408
|
-
});
|
|
11409
|
-
});
|
|
11410
|
-
}
|
|
11411
|
-
}, {
|
|
11412
|
-
key: "getPosition",
|
|
11413
|
-
value: function getPosition(element) {
|
|
11414
11355
|
var transform = element.transformable;
|
|
11415
|
-
|
|
11416
|
-
|
|
11417
|
-
|
|
11418
|
-
|
|
11419
|
-
|
|
11420
|
-
|
|
11421
|
-
|
|
11422
|
-
|
|
11423
|
-
|
|
11424
|
-
|
|
11425
|
-
|
|
11426
|
-
|
|
11427
|
-
|
|
11428
|
-
}
|
|
11429
|
-
}, {
|
|
11430
|
-
key: "getWorldTransform",
|
|
11431
|
-
value: function getWorldTransform(element) {
|
|
11432
|
-
var transform = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : element.transformable;
|
|
11433
|
-
if (!transform.localDirtyFlag && !transform.dirtyFlag) {
|
|
11434
|
-
return transform.worldTransform;
|
|
11435
|
-
}
|
|
11436
|
-
if (element.parentNode && element.parentNode.transformable) {
|
|
11437
|
-
this.getWorldTransform(element.parentNode);
|
|
11356
|
+
if (element.parentNode === null || !element.parentNode.transformable) {
|
|
11357
|
+
this.rotateLocal(element, degrees);
|
|
11358
|
+
} else {
|
|
11359
|
+
var rotation = $quat$1;
|
|
11360
|
+
glMatrix.quat.fromEuler(rotation, degrees[0], degrees[1], degrees[2]);
|
|
11361
|
+
var rot = this.getRotation(element);
|
|
11362
|
+
var parentRot = this.getRotation(element.parentNode);
|
|
11363
|
+
glMatrix.quat.copy($rotate_ParentInvertRotation, parentRot);
|
|
11364
|
+
glMatrix.quat.invert($rotate_ParentInvertRotation, $rotate_ParentInvertRotation);
|
|
11365
|
+
glMatrix.quat.multiply(rotation, $rotate_ParentInvertRotation, rotation);
|
|
11366
|
+
glMatrix.quat.multiply(transform.localRotation, rotation, rot);
|
|
11367
|
+
glMatrix.quat.normalize(transform.localRotation, transform.localRotation);
|
|
11368
|
+
this.dirtyLocalTransform(element, transform);
|
|
11438
11369
|
}
|
|
11439
|
-
this.sync(element, transform);
|
|
11440
|
-
return transform.worldTransform;
|
|
11441
|
-
}
|
|
11442
|
-
}, {
|
|
11443
|
-
key: "getLocalPosition",
|
|
11444
|
-
value: function getLocalPosition(element) {
|
|
11445
|
-
return element.transformable.localPosition;
|
|
11446
|
-
}
|
|
11447
|
-
}, {
|
|
11448
|
-
key: "getLocalRotation",
|
|
11449
|
-
value: function getLocalRotation(element) {
|
|
11450
|
-
return element.transformable.localRotation;
|
|
11451
|
-
}
|
|
11452
|
-
}, {
|
|
11453
|
-
key: "getLocalScale",
|
|
11454
|
-
value: function getLocalScale(element) {
|
|
11455
|
-
return element.transformable.localScale;
|
|
11456
|
-
}
|
|
11457
|
-
}, {
|
|
11458
|
-
key: "getLocalSkew",
|
|
11459
|
-
value: function getLocalSkew(element) {
|
|
11460
|
-
return element.transformable.localSkew;
|
|
11461
11370
|
}
|
|
11462
|
-
}, {
|
|
11463
|
-
key: "calcLocalTransform",
|
|
11464
|
-
value: function calcLocalTransform(transform) {
|
|
11465
|
-
var hasSkew = transform.localSkew[0] !== 0 || transform.localSkew[1] !== 0;
|
|
11466
|
-
if (hasSkew) {
|
|
11467
|
-
glMatrix.mat4.fromRotationTranslationScaleOrigin(transform.localTransform, transform.localRotation, transform.localPosition, glMatrix.vec3.fromValues(1, 1, 1), transform.origin);
|
|
11468
11371
|
|
|
11469
|
-
|
|
11470
|
-
|
|
11471
|
-
|
|
11472
|
-
|
|
11473
|
-
|
|
11474
|
-
|
|
11475
|
-
|
|
11476
|
-
|
|
11477
|
-
|
|
11478
|
-
|
|
11479
|
-
|
|
11480
|
-
|
|
11481
|
-
localRotation = transform.localRotation,
|
|
11482
|
-
localScale = transform.localScale,
|
|
11483
|
-
origin = transform.origin;
|
|
11484
|
-
var hasPosition = localPosition[0] !== 0 || localPosition[1] !== 0 || localPosition[2] !== 0;
|
|
11485
|
-
var hasRotation = localRotation[3] !== 1 || localRotation[0] !== 0 || localRotation[1] !== 0 || localRotation[2] !== 0;
|
|
11486
|
-
var hasScale = localScale[0] !== 1 || localScale[1] !== 1 || localScale[2] !== 1;
|
|
11487
|
-
var hasOrigin = origin[0] !== 0 || origin[1] !== 0 || origin[2] !== 0;
|
|
11488
|
-
if (!hasRotation && !hasScale && !hasOrigin) {
|
|
11489
|
-
if (hasPosition) {
|
|
11490
|
-
glMatrix.mat4.fromTranslation(localTransform, localPosition);
|
|
11491
|
-
} else {
|
|
11492
|
-
glMatrix.mat4.identity(localTransform);
|
|
11493
|
-
}
|
|
11494
|
-
} else {
|
|
11495
|
-
// @see https://github.com/mattdesl/css-mat4/blob/master/index.js
|
|
11496
|
-
glMatrix.mat4.fromRotationTranslationScaleOrigin(localTransform, localRotation, localPosition, localScale, origin);
|
|
11497
|
-
}
|
|
11372
|
+
/**
|
|
11373
|
+
* same as pivot in Pixi.js
|
|
11374
|
+
*
|
|
11375
|
+
* @see https://stackoverflow.com/questions/40748452/how-to-change-css-transform-origin-but-preserve-transformation
|
|
11376
|
+
*/
|
|
11377
|
+
}, {
|
|
11378
|
+
key: "setOrigin",
|
|
11379
|
+
value: function setOrigin(element, origin) {
|
|
11380
|
+
var y = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
11381
|
+
var z = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
11382
|
+
if (typeof origin === 'number') {
|
|
11383
|
+
origin = [origin, y, z];
|
|
11498
11384
|
}
|
|
11499
|
-
}
|
|
11500
|
-
}, {
|
|
11501
|
-
key: "getLocalTransform",
|
|
11502
|
-
value: function getLocalTransform(element) {
|
|
11503
11385
|
var transform = element.transformable;
|
|
11504
|
-
if (transform.
|
|
11505
|
-
|
|
11506
|
-
transform.localDirtyFlag = false;
|
|
11386
|
+
if (origin[0] === transform.origin[0] && origin[1] === transform.origin[1] && origin[2] === transform.origin[2]) {
|
|
11387
|
+
return;
|
|
11507
11388
|
}
|
|
11508
|
-
|
|
11509
|
-
|
|
11510
|
-
|
|
11511
|
-
|
|
11512
|
-
|
|
11513
|
-
|
|
11514
|
-
|
|
11515
|
-
|
|
11516
|
-
|
|
11517
|
-
this.
|
|
11518
|
-
this.setLocalRotation(element, r, undefined, undefined, undefined, false);
|
|
11519
|
-
this.dirtifyLocal(element, element.transformable);
|
|
11389
|
+
var originVec = transform.origin;
|
|
11390
|
+
|
|
11391
|
+
// const delta = vec3.subtract(vec3.create(), origin, originVec);
|
|
11392
|
+
// vec3.add(transform.localPosition, transform.localPosition, delta);
|
|
11393
|
+
|
|
11394
|
+
// update origin
|
|
11395
|
+
originVec[0] = origin[0];
|
|
11396
|
+
originVec[1] = origin[1];
|
|
11397
|
+
originVec[2] = origin[2] || 0;
|
|
11398
|
+
this.dirtyLocalTransform(element, transform);
|
|
11520
11399
|
}
|
|
11400
|
+
|
|
11401
|
+
/**
|
|
11402
|
+
* set euler angles(degrees) in world space
|
|
11403
|
+
*/
|
|
11521
11404
|
}, {
|
|
11522
|
-
key: "
|
|
11523
|
-
value: function
|
|
11524
|
-
|
|
11525
|
-
|
|
11526
|
-
|
|
11527
|
-
|
|
11528
|
-
|
|
11405
|
+
key: "setEulerAngles",
|
|
11406
|
+
value: function setEulerAngles(element, degrees) {
|
|
11407
|
+
var y = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
11408
|
+
var z = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
11409
|
+
if (typeof degrees === 'number') {
|
|
11410
|
+
degrees = glMatrix.vec3.fromValues(degrees, y, z);
|
|
11411
|
+
}
|
|
11412
|
+
var transform = element.transformable;
|
|
11413
|
+
if (element.parentNode === null || !element.parentNode.transformable) {
|
|
11414
|
+
this.setLocalEulerAngles(element, degrees);
|
|
11415
|
+
} else {
|
|
11416
|
+
glMatrix.quat.fromEuler(transform.localRotation, degrees[0], degrees[1], degrees[2]);
|
|
11417
|
+
var parentRotation = this.getRotation(element.parentNode);
|
|
11418
|
+
glMatrix.quat.copy($setEulerAngles_InvParentRot, glMatrix.quat.invert($quat$1, parentRotation));
|
|
11419
|
+
glMatrix.quat.mul(transform.localRotation, transform.localRotation, $setEulerAngles_InvParentRot);
|
|
11420
|
+
this.dirtyLocalTransform(element, transform);
|
|
11421
|
+
}
|
|
11529
11422
|
}
|
|
11423
|
+
|
|
11424
|
+
// #endregion transform
|
|
11425
|
+
// #region bbox ----------------------------------------------------------------
|
|
11530
11426
|
}, {
|
|
11531
11427
|
key: "getTransformedGeometryBounds",
|
|
11532
11428
|
value: function getTransformedGeometryBounds(element) {
|
|
@@ -11564,7 +11460,7 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
11564
11460
|
}, {
|
|
11565
11461
|
key: "getBounds",
|
|
11566
11462
|
value: function getBounds(element) {
|
|
11567
|
-
var
|
|
11463
|
+
var _this = this;
|
|
11568
11464
|
var render = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
11569
11465
|
var _ref4 = element,
|
|
11570
11466
|
renderable = _ref4.renderable;
|
|
@@ -11584,7 +11480,7 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
11584
11480
|
// merge children's aabbs
|
|
11585
11481
|
var children = element.childNodes;
|
|
11586
11482
|
children.forEach(function (child) {
|
|
11587
|
-
var childBounds =
|
|
11483
|
+
var childBounds = _this.getBounds(child, render);
|
|
11588
11484
|
if (childBounds) {
|
|
11589
11485
|
if (!aabb) {
|
|
11590
11486
|
aabb = existedAABB || new AABB();
|
|
@@ -11667,75 +11563,258 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
11667
11563
|
}
|
|
11668
11564
|
return new Rectangle((bbox === null || bbox === void 0 ? void 0 : bbox.left) || 0, (bbox === null || bbox === void 0 ? void 0 : bbox.top) || 0, 0, 0);
|
|
11669
11565
|
}
|
|
11566
|
+
|
|
11567
|
+
// #endregion bbox
|
|
11568
|
+
// #region other ----------------------------------------------------------------
|
|
11569
|
+
}, {
|
|
11570
|
+
key: "internalUpdateTransform",
|
|
11571
|
+
value: function internalUpdateTransform(element) {
|
|
11572
|
+
var _element$parentNode;
|
|
11573
|
+
var parentTransform = (_element$parentNode = element.parentNode) === null || _element$parentNode === void 0 ? void 0 : _element$parentNode.transformable;
|
|
11574
|
+
updateLocalTransform(element.transformable);
|
|
11575
|
+
updateWorldTransform(element.transformable, parentTransform);
|
|
11576
|
+
}
|
|
11577
|
+
}, {
|
|
11578
|
+
key: "internalUpdateElement",
|
|
11579
|
+
value: function internalUpdateElement(element, ancestors) {
|
|
11580
|
+
var _element$ownerDocumen2, _element$transformabl, _element$renderable, _element$renderable2;
|
|
11581
|
+
var enableAttributeUpdateOptimization = ((_element$ownerDocumen2 = element.ownerDocument) === null || _element$ownerDocumen2 === void 0 || (_element$ownerDocumen2 = _element$ownerDocumen2.defaultView) === null || _element$ownerDocumen2 === void 0 || (_element$ownerDocumen2 = _element$ownerDocumen2.getConfig()) === null || _element$ownerDocumen2 === void 0 || (_element$ownerDocumen2 = _element$ownerDocumen2.future) === null || _element$ownerDocumen2 === void 0 ? void 0 : _element$ownerDocumen2.experimentalAttributeUpdateOptimization) === true;
|
|
11582
|
+
var parent = ancestors[ancestors.length - 1];
|
|
11583
|
+
// parent nodes affect child nodes
|
|
11584
|
+
var transformDirty = (parent === null || parent === void 0 ? void 0 : parent.transformDirty) || ((_element$transformabl = element.transformable) === null || _element$transformabl === void 0 ? void 0 : _element$transformabl.localDirtyFlag);
|
|
11585
|
+
if (element.transformable) {
|
|
11586
|
+
var _element$transformabl2;
|
|
11587
|
+
(_element$transformabl2 = element.transformable).dirtyFlag || (_element$transformabl2.dirtyFlag = transformDirty);
|
|
11588
|
+
}
|
|
11589
|
+
this.internalUpdateTransform(element);
|
|
11590
|
+
if (transformDirty) {
|
|
11591
|
+
var _element$dirty;
|
|
11592
|
+
(_element$dirty = element.dirty) === null || _element$dirty === void 0 || _element$dirty.call(element, true, true);
|
|
11593
|
+
}
|
|
11594
|
+
var shapeUpdated = ((_element$renderable = element.renderable) === null || _element$renderable === void 0 ? void 0 : _element$renderable.boundsDirty) || ((_element$renderable2 = element.renderable) === null || _element$renderable2 === void 0 ? void 0 : _element$renderable2.renderBoundsDirty);
|
|
11595
|
+
|
|
11596
|
+
// The transformation matrix of the child node changes,
|
|
11597
|
+
// which will cause the bounding box data of the ancestor node to become outdated.
|
|
11598
|
+
if ((transformDirty || shapeUpdated) && (parent === null || parent === void 0 ? void 0 : parent.shapeUpdated) === false && enableAttributeUpdateOptimization) {
|
|
11599
|
+
var tempElIndex = ancestors.length - 1;
|
|
11600
|
+
while (tempElIndex >= 0) {
|
|
11601
|
+
var _dirty, _ref5;
|
|
11602
|
+
var tempEl = ancestors[tempElIndex];
|
|
11603
|
+
if (tempEl.shapeUpdated) {
|
|
11604
|
+
break;
|
|
11605
|
+
}
|
|
11606
|
+
(_dirty = (_ref5 = tempEl.node).dirty) === null || _dirty === void 0 || _dirty.call(_ref5, true, true);
|
|
11607
|
+
tempEl.shapeUpdated = true;
|
|
11608
|
+
tempElIndex -= 1;
|
|
11609
|
+
}
|
|
11610
|
+
}
|
|
11611
|
+
return transformDirty;
|
|
11612
|
+
}
|
|
11613
|
+
}, {
|
|
11614
|
+
key: "syncHierarchy",
|
|
11615
|
+
value: function syncHierarchy(rootNode) {
|
|
11616
|
+
var _transformable, _transformable2;
|
|
11617
|
+
// console.log('syncHierarchy');
|
|
11618
|
+
var stack = [rootNode];
|
|
11619
|
+
var ancestors = rootNode.parentNode ? [{
|
|
11620
|
+
node: rootNode.parentNode,
|
|
11621
|
+
transformDirty: ((_transformable = rootNode.parentNode.transformable) === null || _transformable === void 0 ? void 0 : _transformable.localDirtyFlag) || ((_transformable2 = rootNode.parentNode.transformable) === null || _transformable2 === void 0 ? void 0 : _transformable2.dirtyFlag),
|
|
11622
|
+
shapeUpdated: false
|
|
11623
|
+
}] : [];
|
|
11624
|
+
while (stack.length > 0) {
|
|
11625
|
+
var node = stack.pop();
|
|
11626
|
+
var parent = ancestors[ancestors.length - 1];
|
|
11627
|
+
while (ancestors.length > 0 && node.parentNode !== parent.node) {
|
|
11628
|
+
parent = ancestors.pop();
|
|
11629
|
+
}
|
|
11630
|
+
var transformDirty = this.internalUpdateElement(node, ancestors);
|
|
11631
|
+
if (node.childNodes.length > 0) {
|
|
11632
|
+
for (var i = node.childNodes.length - 1; i >= 0; i--) {
|
|
11633
|
+
stack.push(node.childNodes[i]);
|
|
11634
|
+
}
|
|
11635
|
+
ancestors.push({
|
|
11636
|
+
node: node,
|
|
11637
|
+
transformDirty: transformDirty,
|
|
11638
|
+
shapeUpdated: false
|
|
11639
|
+
});
|
|
11640
|
+
}
|
|
11641
|
+
}
|
|
11642
|
+
}
|
|
11643
|
+
}, {
|
|
11644
|
+
key: "dirtyLocalTransform",
|
|
11645
|
+
value: function dirtyLocalTransform(element, transform) {
|
|
11646
|
+
if (isInFragment(element)) return;
|
|
11647
|
+
if (!transform.localDirtyFlag) {
|
|
11648
|
+
transform.localDirtyFlag = true;
|
|
11649
|
+
if (!transform.dirtyFlag) {
|
|
11650
|
+
this.dirtyWorldTransform(element, transform);
|
|
11651
|
+
}
|
|
11652
|
+
}
|
|
11653
|
+
}
|
|
11654
|
+
}, {
|
|
11655
|
+
key: "dirtyWorldTransform",
|
|
11656
|
+
value: function dirtyWorldTransform(element, transform) {
|
|
11657
|
+
this.dirtifyWorldInternal(element, transform);
|
|
11658
|
+
this.dirtyToRoot(element, true);
|
|
11659
|
+
}
|
|
11670
11660
|
}, {
|
|
11671
11661
|
key: "dirtifyWorldInternal",
|
|
11672
11662
|
value: function dirtifyWorldInternal(element, transform) {
|
|
11673
|
-
var
|
|
11663
|
+
var _element$ownerDocumen3,
|
|
11664
|
+
_this2 = this;
|
|
11665
|
+
var enableAttributeUpdateOptimization = ((_element$ownerDocumen3 = element.ownerDocument) === null || _element$ownerDocumen3 === void 0 || (_element$ownerDocumen3 = _element$ownerDocumen3.defaultView) === null || _element$ownerDocumen3 === void 0 || (_element$ownerDocumen3 = _element$ownerDocumen3.getConfig()) === null || _element$ownerDocumen3 === void 0 || (_element$ownerDocumen3 = _element$ownerDocumen3.future) === null || _element$ownerDocumen3 === void 0 ? void 0 : _element$ownerDocumen3.experimentalAttributeUpdateOptimization) === true;
|
|
11674
11666
|
if (!transform.dirtyFlag) {
|
|
11675
11667
|
transform.dirtyFlag = true;
|
|
11676
|
-
|
|
11677
|
-
|
|
11678
|
-
|
|
11679
|
-
|
|
11680
|
-
|
|
11681
|
-
}
|
|
11682
|
-
});
|
|
11683
|
-
var _ref5 = element,
|
|
11684
|
-
renderable = _ref5.renderable;
|
|
11685
|
-
if (renderable) {
|
|
11686
|
-
renderable.renderBoundsDirty = true;
|
|
11687
|
-
renderable.boundsDirty = true;
|
|
11688
|
-
renderable.dirty = true;
|
|
11668
|
+
element.dirty(true, true);
|
|
11669
|
+
if (!enableAttributeUpdateOptimization) {
|
|
11670
|
+
element.childNodes.forEach(function (child) {
|
|
11671
|
+
var childTransform = child.transformable;
|
|
11672
|
+
_this2.dirtifyWorldInternal(child, childTransform);
|
|
11673
|
+
});
|
|
11689
11674
|
}
|
|
11690
11675
|
}
|
|
11691
11676
|
}
|
|
11692
11677
|
}, {
|
|
11693
|
-
key: "
|
|
11694
|
-
value: function
|
|
11678
|
+
key: "dirtyToRoot",
|
|
11679
|
+
value: function dirtyToRoot(element) {
|
|
11680
|
+
var _element$ownerDocumen4;
|
|
11681
|
+
var affectChildren = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
11682
|
+
var p = element;
|
|
11683
|
+
var enableAttributeUpdateOptimization = ((_element$ownerDocumen4 = element.ownerDocument) === null || _element$ownerDocumen4 === void 0 || (_element$ownerDocumen4 = _element$ownerDocumen4.defaultView) === null || _element$ownerDocumen4 === void 0 || (_element$ownerDocumen4 = _element$ownerDocumen4.getConfig()) === null || _element$ownerDocumen4 === void 0 || (_element$ownerDocumen4 = _element$ownerDocumen4.future) === null || _element$ownerDocumen4 === void 0 ? void 0 : _element$ownerDocumen4.experimentalAttributeUpdateOptimization) === true;
|
|
11684
|
+
while (p) {
|
|
11685
|
+
var _dirty2, _ref6;
|
|
11686
|
+
(_dirty2 = (_ref6 = p).dirty) === null || _dirty2 === void 0 || _dirty2.call(_ref6, true, true);
|
|
11687
|
+
if (enableAttributeUpdateOptimization) {
|
|
11688
|
+
break;
|
|
11689
|
+
} else {
|
|
11690
|
+
p = p.parentNode;
|
|
11691
|
+
}
|
|
11692
|
+
}
|
|
11693
|
+
if (affectChildren) {
|
|
11694
|
+
element.forEach(function (e) {
|
|
11695
|
+
var _e$dirty;
|
|
11696
|
+
(_e$dirty = e.dirty) === null || _e$dirty === void 0 || _e$dirty.call(e, true, true);
|
|
11697
|
+
});
|
|
11698
|
+
}
|
|
11699
|
+
this.informDependentDisplayObjects(element);
|
|
11700
|
+
this.pendingEvents.set(element, affectChildren);
|
|
11701
|
+
}
|
|
11702
|
+
}, {
|
|
11703
|
+
key: "dirtifyFragment",
|
|
11704
|
+
value: function dirtifyFragment(element) {
|
|
11705
|
+
var _dirty3, _ref7;
|
|
11695
11706
|
var transform = element.transformable;
|
|
11696
|
-
if (transform
|
|
11697
|
-
|
|
11707
|
+
if (transform) {
|
|
11708
|
+
transform.dirtyFlag = true;
|
|
11709
|
+
transform.localDirtyFlag = true;
|
|
11698
11710
|
}
|
|
11699
|
-
|
|
11700
|
-
|
|
11701
|
-
|
|
11711
|
+
(_dirty3 = (_ref7 = element).dirty) === null || _dirty3 === void 0 || _dirty3.call(_ref7, true, true);
|
|
11712
|
+
var length = element.childNodes.length;
|
|
11713
|
+
for (var i = 0; i < length; i++) {
|
|
11714
|
+
this.dirtifyFragment(element.childNodes[i]);
|
|
11702
11715
|
}
|
|
11703
|
-
|
|
11704
|
-
|
|
11705
|
-
this.syncHierarchy(children[i]);
|
|
11716
|
+
if (element.nodeName === Shape.FRAGMENT) {
|
|
11717
|
+
this.pendingEvents.set(element, false);
|
|
11706
11718
|
}
|
|
11707
11719
|
}
|
|
11708
11720
|
}, {
|
|
11709
|
-
key: "
|
|
11710
|
-
value: function
|
|
11711
|
-
|
|
11712
|
-
|
|
11713
|
-
|
|
11714
|
-
|
|
11715
|
-
|
|
11716
|
-
|
|
11717
|
-
|
|
11718
|
-
|
|
11719
|
-
|
|
11721
|
+
key: "triggerPendingEvents",
|
|
11722
|
+
value: function triggerPendingEvents() {
|
|
11723
|
+
var _this3 = this;
|
|
11724
|
+
var triggered = new Set();
|
|
11725
|
+
var enableCancelEventPropagation;
|
|
11726
|
+
var enableAttributeUpdateOptimization;
|
|
11727
|
+
var trigger = function trigger(element, detail) {
|
|
11728
|
+
if (!element.isConnected || triggered.has(element) || element.nodeName === Shape.FRAGMENT) {
|
|
11729
|
+
return;
|
|
11730
|
+
}
|
|
11731
|
+
_this3.boundsChangedEvent.detail = detail;
|
|
11732
|
+
_this3.boundsChangedEvent.target = element;
|
|
11733
|
+
if (element.isMutationObserved) {
|
|
11734
|
+
element.dispatchEvent(_this3.boundsChangedEvent);
|
|
11720
11735
|
} else {
|
|
11721
|
-
|
|
11722
|
-
|
|
11723
|
-
|
|
11736
|
+
if (enableCancelEventPropagation === undefined) {
|
|
11737
|
+
var _element$ownerDocumen5;
|
|
11738
|
+
enableCancelEventPropagation = ((_element$ownerDocumen5 = element.ownerDocument.defaultView) === null || _element$ownerDocumen5 === void 0 || (_element$ownerDocumen5 = _element$ownerDocumen5.getConfig()) === null || _element$ownerDocumen5 === void 0 || (_element$ownerDocumen5 = _element$ownerDocumen5.future) === null || _element$ownerDocumen5 === void 0 ? void 0 : _element$ownerDocumen5.experimentalCancelEventPropagation) === true;
|
|
11739
|
+
}
|
|
11740
|
+
element.ownerDocument.defaultView.dispatchEvent(_this3.boundsChangedEvent, true, enableCancelEventPropagation);
|
|
11724
11741
|
}
|
|
11725
|
-
|
|
11726
|
-
}
|
|
11742
|
+
triggered.add(element);
|
|
11743
|
+
};
|
|
11744
|
+
this.pendingEvents.forEach(function (affectChildren, element) {
|
|
11745
|
+
if (element.nodeName === Shape.FRAGMENT) {
|
|
11746
|
+
return;
|
|
11747
|
+
}
|
|
11748
|
+
if (enableAttributeUpdateOptimization === undefined) {
|
|
11749
|
+
var _element$ownerDocumen6;
|
|
11750
|
+
enableAttributeUpdateOptimization = ((_element$ownerDocumen6 = element.ownerDocument) === null || _element$ownerDocumen6 === void 0 || (_element$ownerDocumen6 = _element$ownerDocumen6.defaultView) === null || _element$ownerDocumen6 === void 0 || (_element$ownerDocumen6 = _element$ownerDocumen6.getConfig()) === null || _element$ownerDocumen6 === void 0 || (_element$ownerDocumen6 = _element$ownerDocumen6.future) === null || _element$ownerDocumen6 === void 0 ? void 0 : _element$ownerDocumen6.experimentalAttributeUpdateOptimization) === true;
|
|
11751
|
+
}
|
|
11752
|
+
$triggerPendingEvents_detail.affectChildren = affectChildren;
|
|
11753
|
+
if (enableAttributeUpdateOptimization) {
|
|
11754
|
+
trigger(element, $triggerPendingEvents_detail);
|
|
11755
|
+
} else {
|
|
11756
|
+
// eslint-disable-next-line no-lonely-if
|
|
11757
|
+
if (affectChildren) {
|
|
11758
|
+
element.forEach(function (e) {
|
|
11759
|
+
trigger(e, $triggerPendingEvents_detail);
|
|
11760
|
+
});
|
|
11761
|
+
} else {
|
|
11762
|
+
trigger(element, $triggerPendingEvents_detail);
|
|
11763
|
+
}
|
|
11764
|
+
}
|
|
11765
|
+
});
|
|
11766
|
+
triggered.clear();
|
|
11767
|
+
this.clearPendingEvents();
|
|
11727
11768
|
}
|
|
11728
11769
|
}, {
|
|
11729
|
-
key: "
|
|
11730
|
-
value: function
|
|
11731
|
-
|
|
11732
|
-
|
|
11733
|
-
|
|
11734
|
-
|
|
11735
|
-
|
|
11770
|
+
key: "clearPendingEvents",
|
|
11771
|
+
value: function clearPendingEvents() {
|
|
11772
|
+
this.pendingEvents.clear();
|
|
11773
|
+
}
|
|
11774
|
+
}, {
|
|
11775
|
+
key: "updateDisplayObjectDependency",
|
|
11776
|
+
value: function updateDisplayObjectDependency(name, oldPath, newPath, object) {
|
|
11777
|
+
// clear ref to old clip path
|
|
11778
|
+
if (oldPath && oldPath !== newPath) {
|
|
11779
|
+
var oldDependencyMap = this.displayObjectDependencyMap.get(oldPath);
|
|
11780
|
+
if (oldDependencyMap && oldDependencyMap[name]) {
|
|
11781
|
+
var index = oldDependencyMap[name].indexOf(object);
|
|
11782
|
+
oldDependencyMap[name].splice(index, 1);
|
|
11783
|
+
}
|
|
11784
|
+
}
|
|
11785
|
+
if (newPath) {
|
|
11786
|
+
var newDependencyMap = this.displayObjectDependencyMap.get(newPath);
|
|
11787
|
+
if (!newDependencyMap) {
|
|
11788
|
+
this.displayObjectDependencyMap.set(newPath, {});
|
|
11789
|
+
newDependencyMap = this.displayObjectDependencyMap.get(newPath);
|
|
11790
|
+
}
|
|
11791
|
+
if (!newDependencyMap[name]) {
|
|
11792
|
+
newDependencyMap[name] = [];
|
|
11736
11793
|
}
|
|
11737
|
-
|
|
11794
|
+
newDependencyMap[name].push(object);
|
|
11795
|
+
}
|
|
11796
|
+
}
|
|
11797
|
+
}, {
|
|
11798
|
+
key: "informDependentDisplayObjects",
|
|
11799
|
+
value: function informDependentDisplayObjects(object) {
|
|
11800
|
+
var _object$ownerDocument,
|
|
11801
|
+
_this4 = this;
|
|
11802
|
+
var dependencyMap = this.displayObjectDependencyMap.get(object);
|
|
11803
|
+
if (!dependencyMap) {
|
|
11804
|
+
return;
|
|
11738
11805
|
}
|
|
11806
|
+
var enableCancelEventPropagation = (_object$ownerDocument = object.ownerDocument) === null || _object$ownerDocument === void 0 || (_object$ownerDocument = _object$ownerDocument.defaultView) === null || _object$ownerDocument === void 0 || (_object$ownerDocument = _object$ownerDocument.getConfig()) === null || _object$ownerDocument === void 0 || (_object$ownerDocument = _object$ownerDocument.future) === null || _object$ownerDocument === void 0 ? void 0 : _object$ownerDocument.experimentalCancelEventPropagation;
|
|
11807
|
+
Object.keys(dependencyMap).forEach(function (name) {
|
|
11808
|
+
dependencyMap[name].forEach(function (target) {
|
|
11809
|
+
_this4.dirtyToRoot(target, true);
|
|
11810
|
+
target.dispatchEvent(new MutationEvent(ElementEvent.ATTR_MODIFIED, target, _this4, _this4, name, MutationEvent.MODIFICATION, _this4, _this4), enableCancelEventPropagation, enableCancelEventPropagation);
|
|
11811
|
+
if (target.isCustomElement && target.isConnected) {
|
|
11812
|
+
if (target.attributeChangedCallback) {
|
|
11813
|
+
target.attributeChangedCallback(name, _this4, _this4);
|
|
11814
|
+
}
|
|
11815
|
+
}
|
|
11816
|
+
});
|
|
11817
|
+
});
|
|
11739
11818
|
}
|
|
11740
11819
|
}]);
|
|
11741
11820
|
}();
|
|
@@ -12046,7 +12125,8 @@ var TextService = /*#__PURE__*/function () {
|
|
|
12046
12125
|
var lines = [];
|
|
12047
12126
|
var currentLineIndex = 0;
|
|
12048
12127
|
var currentLineWidth = 0;
|
|
12049
|
-
|
|
12128
|
+
// @see https://github.com/antvis/G/issues/1932
|
|
12129
|
+
var prevLineLastCharIndex = -1;
|
|
12050
12130
|
var cache = {};
|
|
12051
12131
|
var calcWidth = function calcWidth(txt) {
|
|
12052
12132
|
return _this2.getFromCache(txt, letterSpacing, cache, context);
|
|
@@ -12070,7 +12150,9 @@ var TextService = /*#__PURE__*/function () {
|
|
|
12070
12150
|
txtLastCharIndex += 1;
|
|
12071
12151
|
lineTxt += chars[txtLastCharIndex];
|
|
12072
12152
|
}
|
|
12073
|
-
while (calcWidth(lineTxt) > widthThreshold &&
|
|
12153
|
+
while (calcWidth(lineTxt) > widthThreshold &&
|
|
12154
|
+
// @see https://github.com/antvis/G/issues/1932
|
|
12155
|
+
txtLastCharIndex >= txtStartCharIndex) {
|
|
12074
12156
|
txtLastCharIndex -= 1;
|
|
12075
12157
|
lineTxt = lineTxt.slice(0, -1);
|
|
12076
12158
|
}
|
|
@@ -12112,6 +12194,18 @@ var TextService = /*#__PURE__*/function () {
|
|
|
12112
12194
|
lines[currentLineIndex] = '';
|
|
12113
12195
|
continue;
|
|
12114
12196
|
}
|
|
12197
|
+
|
|
12198
|
+
// If current line is empty and char width exceeds max width, no need to continue
|
|
12199
|
+
if (currentLineWidth === 0 && charWidth > maxWidth) {
|
|
12200
|
+
// Only add ellipsis if it can fit in the line
|
|
12201
|
+
if (ellipsis && ellipsisWidth <= maxWidth) {
|
|
12202
|
+
lines[currentLineIndex] = ellipsis;
|
|
12203
|
+
} else {
|
|
12204
|
+
lines[currentLineIndex] = '';
|
|
12205
|
+
}
|
|
12206
|
+
parsedStyle.isOverflowing = true;
|
|
12207
|
+
break;
|
|
12208
|
+
}
|
|
12115
12209
|
if (currentLineWidth > 0 && currentLineWidth + charWidth > maxWidth) {
|
|
12116
12210
|
var result = findCharIndexClosestWidthThreshold(lines[currentLineIndex], i - 1, prevLineLastCharIndex + 1, maxWidth);
|
|
12117
12211
|
if (result.txtLastCharIndex !== i - 1) {
|
|
@@ -12293,24 +12387,9 @@ var Element = /*#__PURE__*/function (_Node) {
|
|
|
12293
12387
|
* Unique id.
|
|
12294
12388
|
*/
|
|
12295
12389
|
_this.entity = entityCounter++;
|
|
12296
|
-
_this.renderable = {
|
|
12297
|
-
bounds: undefined,
|
|
12298
|
-
boundsDirty: true,
|
|
12299
|
-
renderBounds: undefined,
|
|
12300
|
-
renderBoundsDirty: true,
|
|
12301
|
-
dirtyRenderBounds: undefined,
|
|
12302
|
-
dirty: false
|
|
12303
|
-
};
|
|
12304
|
-
_this.cullable = {
|
|
12305
|
-
strategy: Strategy.Standard,
|
|
12306
|
-
visibilityPlaneMask: -1,
|
|
12307
|
-
visible: true,
|
|
12308
|
-
enable: true
|
|
12309
|
-
};
|
|
12310
12390
|
_this.transformable = {
|
|
12311
12391
|
dirtyFlag: false,
|
|
12312
12392
|
localDirtyFlag: false,
|
|
12313
|
-
frozen: false,
|
|
12314
12393
|
localPosition: [0, 0, 0],
|
|
12315
12394
|
localRotation: [0, 0, 0, 1],
|
|
12316
12395
|
localScale: [1, 1, 1],
|
|
@@ -12322,6 +12401,25 @@ var Element = /*#__PURE__*/function (_Node) {
|
|
|
12322
12401
|
worldTransform: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],
|
|
12323
12402
|
origin: [0, 0, 0]
|
|
12324
12403
|
};
|
|
12404
|
+
_this.renderable = {
|
|
12405
|
+
bounds: undefined,
|
|
12406
|
+
boundsDirty: true,
|
|
12407
|
+
renderBounds: undefined,
|
|
12408
|
+
renderBoundsDirty: true,
|
|
12409
|
+
dirtyRenderBounds: undefined,
|
|
12410
|
+
dirty: false
|
|
12411
|
+
};
|
|
12412
|
+
_this.geometry = {
|
|
12413
|
+
contentBounds: undefined,
|
|
12414
|
+
renderBounds: undefined,
|
|
12415
|
+
dirty: true
|
|
12416
|
+
};
|
|
12417
|
+
_this.cullable = {
|
|
12418
|
+
strategy: Strategy.Standard,
|
|
12419
|
+
visibilityPlaneMask: -1,
|
|
12420
|
+
visible: true,
|
|
12421
|
+
enable: true
|
|
12422
|
+
};
|
|
12325
12423
|
_this.sortable = {
|
|
12326
12424
|
dirty: false,
|
|
12327
12425
|
sorted: undefined,
|
|
@@ -12329,11 +12427,6 @@ var Element = /*#__PURE__*/function (_Node) {
|
|
|
12329
12427
|
dirtyChildren: [],
|
|
12330
12428
|
dirtyReason: undefined
|
|
12331
12429
|
};
|
|
12332
|
-
_this.geometry = {
|
|
12333
|
-
contentBounds: undefined,
|
|
12334
|
-
renderBounds: undefined,
|
|
12335
|
-
dirty: true
|
|
12336
|
-
};
|
|
12337
12430
|
_this.rBushNode = {
|
|
12338
12431
|
aabb: undefined
|
|
12339
12432
|
};
|
|
@@ -12349,10 +12442,6 @@ var Element = /*#__PURE__*/function (_Node) {
|
|
|
12349
12442
|
*/
|
|
12350
12443
|
_this.clientTop = 0;
|
|
12351
12444
|
_this.clientLeft = 0;
|
|
12352
|
-
/**
|
|
12353
|
-
* is destroyed or not
|
|
12354
|
-
*/
|
|
12355
|
-
_this.destroyed = false;
|
|
12356
12445
|
/**
|
|
12357
12446
|
* compatible with `style`
|
|
12358
12447
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style
|
|
@@ -12390,6 +12479,22 @@ var Element = /*#__PURE__*/function (_Node) {
|
|
|
12390
12479
|
}
|
|
12391
12480
|
_inherits(Element, _Node);
|
|
12392
12481
|
return _createClass(Element, [{
|
|
12482
|
+
key: "dirty",
|
|
12483
|
+
value:
|
|
12484
|
+
/**
|
|
12485
|
+
* @param flag - default `true`, whether the object needs to be updated
|
|
12486
|
+
* @param updateShape - default `false`, whether the bounding box of the object is updated
|
|
12487
|
+
*/
|
|
12488
|
+
function dirty() {
|
|
12489
|
+
var flag = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
12490
|
+
var updateShape = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
12491
|
+
this.renderable.dirty = flag;
|
|
12492
|
+
if (updateShape) {
|
|
12493
|
+
this.renderable.boundsDirty = flag;
|
|
12494
|
+
this.renderable.renderBoundsDirty = flag;
|
|
12495
|
+
}
|
|
12496
|
+
}
|
|
12497
|
+
}, {
|
|
12393
12498
|
key: "className",
|
|
12394
12499
|
get:
|
|
12395
12500
|
/**
|
|
@@ -12529,10 +12634,12 @@ var Element = /*#__PURE__*/function (_Node) {
|
|
|
12529
12634
|
}, {
|
|
12530
12635
|
key: "removeChild",
|
|
12531
12636
|
value: function removeChild(child) {
|
|
12532
|
-
var _child$ownerDocument;
|
|
12637
|
+
var _this$ownerDocument2, _child$ownerDocument;
|
|
12638
|
+
var enableCancelEventPropagation = ((_this$ownerDocument2 = this.ownerDocument) === null || _this$ownerDocument2 === void 0 || (_this$ownerDocument2 = _this$ownerDocument2.defaultView) === null || _this$ownerDocument2 === void 0 || (_this$ownerDocument2 = _this$ownerDocument2.getConfig().future) === null || _this$ownerDocument2 === void 0 ? void 0 : _this$ownerDocument2.experimentalCancelEventPropagation) === true;
|
|
12639
|
+
|
|
12533
12640
|
// should emit on itself before detach
|
|
12534
12641
|
removedEvent.relatedNode = this;
|
|
12535
|
-
child.dispatchEvent(removedEvent);
|
|
12642
|
+
child.dispatchEvent(removedEvent, enableCancelEventPropagation, enableCancelEventPropagation);
|
|
12536
12643
|
if ((_child$ownerDocument = child.ownerDocument) !== null && _child$ownerDocument !== void 0 && _child$ownerDocument.defaultView) {
|
|
12537
12644
|
child.ownerDocument.defaultView.unmountChildren(child);
|
|
12538
12645
|
}
|
|
@@ -12759,11 +12866,14 @@ var Element = /*#__PURE__*/function (_Node) {
|
|
|
12759
12866
|
}, {
|
|
12760
12867
|
key: "destroy",
|
|
12761
12868
|
value: function destroy() {
|
|
12869
|
+
var _this$ownerDocument3;
|
|
12870
|
+
var enableCancelEventPropagation = ((_this$ownerDocument3 = this.ownerDocument) === null || _this$ownerDocument3 === void 0 || (_this$ownerDocument3 = _this$ownerDocument3.defaultView) === null || _this$ownerDocument3 === void 0 || (_this$ownerDocument3 = _this$ownerDocument3.getConfig().future) === null || _this$ownerDocument3 === void 0 ? void 0 : _this$ownerDocument3.experimentalCancelEventPropagation) === true;
|
|
12871
|
+
|
|
12762
12872
|
// fix https://github.com/antvis/G/issues/1813
|
|
12763
12873
|
this.destroyChildren();
|
|
12764
12874
|
|
|
12765
12875
|
// destroy itself before remove
|
|
12766
|
-
this.dispatchEvent(destroyEvent);
|
|
12876
|
+
this.dispatchEvent(destroyEvent, enableCancelEventPropagation, enableCancelEventPropagation);
|
|
12767
12877
|
|
|
12768
12878
|
// remove from scenegraph first
|
|
12769
12879
|
this.remove();
|
|
@@ -13094,7 +13204,7 @@ var DisplayObject = /*#__PURE__*/function (_Element) {
|
|
|
13094
13204
|
runtime.styleValueRegistry.processProperties(this, attributes, options);
|
|
13095
13205
|
|
|
13096
13206
|
// redraw at next frame
|
|
13097
|
-
this.
|
|
13207
|
+
this.dirty();
|
|
13098
13208
|
}
|
|
13099
13209
|
}, {
|
|
13100
13210
|
key: "setAttribute",
|
|
@@ -13120,13 +13230,15 @@ var DisplayObject = /*#__PURE__*/function (_Element) {
|
|
|
13120
13230
|
key: "internalSetAttribute",
|
|
13121
13231
|
value: function internalSetAttribute(name, value) {
|
|
13122
13232
|
var parseOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
13123
|
-
var renderable = this.renderable;
|
|
13124
13233
|
var oldValue = this.attributes[name];
|
|
13125
13234
|
var oldParsedValue = this.parsedStyle[name];
|
|
13126
13235
|
runtime.styleValueRegistry.processProperties(this, _defineProperty({}, name, value), parseOptions);
|
|
13127
13236
|
|
|
13128
13237
|
// redraw at next frame
|
|
13129
|
-
|
|
13238
|
+
this.dirty();
|
|
13239
|
+
|
|
13240
|
+
// return;
|
|
13241
|
+
|
|
13130
13242
|
var newParsedValue = this.parsedStyle[name];
|
|
13131
13243
|
if (this.isConnected) {
|
|
13132
13244
|
attrModifiedEvent.relatedNode = this;
|
|
@@ -13138,8 +13250,10 @@ var DisplayObject = /*#__PURE__*/function (_Element) {
|
|
|
13138
13250
|
if (this.isMutationObserved) {
|
|
13139
13251
|
this.dispatchEvent(attrModifiedEvent);
|
|
13140
13252
|
} else {
|
|
13253
|
+
var _this$ownerDocument$d;
|
|
13254
|
+
var enableCancelEventPropagation = ((_this$ownerDocument$d = this.ownerDocument.defaultView.getConfig().future) === null || _this$ownerDocument$d === void 0 ? void 0 : _this$ownerDocument$d.experimentalCancelEventPropagation) === true;
|
|
13141
13255
|
attrModifiedEvent.target = this;
|
|
13142
|
-
this.ownerDocument.defaultView.dispatchEvent(attrModifiedEvent, true);
|
|
13256
|
+
this.ownerDocument.defaultView.dispatchEvent(attrModifiedEvent, true, enableCancelEventPropagation);
|
|
13143
13257
|
}
|
|
13144
13258
|
}
|
|
13145
13259
|
if (this.isCustomElement && this.isConnected || !this.isCustomElement) {
|
|
@@ -15032,7 +15146,7 @@ var Document = /*#__PURE__*/function (_Node) {
|
|
|
15032
15146
|
value: (function () {
|
|
15033
15147
|
var _elementFromPoint = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(x, y) {
|
|
15034
15148
|
var _this$defaultView$can2, viewportX, viewportY, _this$defaultView$get3, width, height, _this$defaultView$vie2, clientX, clientY, _yield$this$defaultVi, picked;
|
|
15035
|
-
return _regeneratorRuntime().wrap(function
|
|
15149
|
+
return _regeneratorRuntime().wrap(function (_context) {
|
|
15036
15150
|
while (1) switch (_context.prev = _context.next) {
|
|
15037
15151
|
case 0:
|
|
15038
15152
|
_this$defaultView$can2 = this.defaultView.canvas2Viewport({
|
|
@@ -15041,16 +15155,16 @@ var Document = /*#__PURE__*/function (_Node) {
|
|
|
15041
15155
|
}), viewportX = _this$defaultView$can2.x, viewportY = _this$defaultView$can2.y;
|
|
15042
15156
|
_this$defaultView$get3 = this.defaultView.getConfig(), width = _this$defaultView$get3.width, height = _this$defaultView$get3.height; // outside canvas' viewport
|
|
15043
15157
|
if (!(viewportX < 0 || viewportY < 0 || viewportX > width || viewportY > height)) {
|
|
15044
|
-
_context.next =
|
|
15158
|
+
_context.next = 1;
|
|
15045
15159
|
break;
|
|
15046
15160
|
}
|
|
15047
15161
|
return _context.abrupt("return", null);
|
|
15048
|
-
case
|
|
15162
|
+
case 1:
|
|
15049
15163
|
_this$defaultView$vie2 = this.defaultView.viewport2Client({
|
|
15050
15164
|
x: viewportX,
|
|
15051
15165
|
y: viewportY
|
|
15052
15166
|
}), clientX = _this$defaultView$vie2.x, clientY = _this$defaultView$vie2.y;
|
|
15053
|
-
_context.next =
|
|
15167
|
+
_context.next = 2;
|
|
15054
15168
|
return this.defaultView.getRenderingService().hooks.pick.promise({
|
|
15055
15169
|
topmost: true,
|
|
15056
15170
|
position: {
|
|
@@ -15063,11 +15177,11 @@ var Document = /*#__PURE__*/function (_Node) {
|
|
|
15063
15177
|
},
|
|
15064
15178
|
picked: []
|
|
15065
15179
|
});
|
|
15066
|
-
case
|
|
15180
|
+
case 2:
|
|
15067
15181
|
_yield$this$defaultVi = _context.sent;
|
|
15068
15182
|
picked = _yield$this$defaultVi.picked;
|
|
15069
15183
|
return _context.abrupt("return", picked && picked[0] || this.documentElement);
|
|
15070
|
-
case
|
|
15184
|
+
case 3:
|
|
15071
15185
|
case "end":
|
|
15072
15186
|
return _context.stop();
|
|
15073
15187
|
}
|
|
@@ -15129,7 +15243,7 @@ var Document = /*#__PURE__*/function (_Node) {
|
|
|
15129
15243
|
value: (function () {
|
|
15130
15244
|
var _elementsFromPoint = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(x, y) {
|
|
15131
15245
|
var _this$defaultView$can4, viewportX, viewportY, _this$defaultView$get6, width, height, _this$defaultView$vie4, clientX, clientY, _yield$this$defaultVi2, picked;
|
|
15132
|
-
return _regeneratorRuntime().wrap(function
|
|
15246
|
+
return _regeneratorRuntime().wrap(function (_context2) {
|
|
15133
15247
|
while (1) switch (_context2.prev = _context2.next) {
|
|
15134
15248
|
case 0:
|
|
15135
15249
|
_this$defaultView$can4 = this.defaultView.canvas2Viewport({
|
|
@@ -15138,16 +15252,16 @@ var Document = /*#__PURE__*/function (_Node) {
|
|
|
15138
15252
|
}), viewportX = _this$defaultView$can4.x, viewportY = _this$defaultView$can4.y;
|
|
15139
15253
|
_this$defaultView$get6 = this.defaultView.getConfig(), width = _this$defaultView$get6.width, height = _this$defaultView$get6.height; // outside canvas' viewport
|
|
15140
15254
|
if (!(viewportX < 0 || viewportY < 0 || viewportX > width || viewportY > height)) {
|
|
15141
|
-
_context2.next =
|
|
15255
|
+
_context2.next = 1;
|
|
15142
15256
|
break;
|
|
15143
15257
|
}
|
|
15144
15258
|
return _context2.abrupt("return", []);
|
|
15145
|
-
case
|
|
15259
|
+
case 1:
|
|
15146
15260
|
_this$defaultView$vie4 = this.defaultView.viewport2Client({
|
|
15147
15261
|
x: viewportX,
|
|
15148
15262
|
y: viewportY
|
|
15149
15263
|
}), clientX = _this$defaultView$vie4.x, clientY = _this$defaultView$vie4.y;
|
|
15150
|
-
_context2.next =
|
|
15264
|
+
_context2.next = 2;
|
|
15151
15265
|
return this.defaultView.getRenderingService().hooks.pick.promise({
|
|
15152
15266
|
topmost: false,
|
|
15153
15267
|
position: {
|
|
@@ -15160,14 +15274,14 @@ var Document = /*#__PURE__*/function (_Node) {
|
|
|
15160
15274
|
},
|
|
15161
15275
|
picked: []
|
|
15162
15276
|
});
|
|
15163
|
-
case
|
|
15277
|
+
case 2:
|
|
15164
15278
|
_yield$this$defaultVi2 = _context2.sent;
|
|
15165
15279
|
picked = _yield$this$defaultVi2.picked;
|
|
15166
15280
|
if (picked[picked.length - 1] !== this.documentElement) {
|
|
15167
15281
|
picked.push(this.documentElement);
|
|
15168
15282
|
}
|
|
15169
15283
|
return _context2.abrupt("return", picked);
|
|
15170
|
-
case
|
|
15284
|
+
case 3:
|
|
15171
15285
|
case "end":
|
|
15172
15286
|
return _context2.stop();
|
|
15173
15287
|
}
|
|
@@ -15272,12 +15386,14 @@ var CullingPlugin = /*#__PURE__*/function () {
|
|
|
15272
15386
|
return _createClass(CullingPlugin, [{
|
|
15273
15387
|
key: "apply",
|
|
15274
15388
|
value: function apply(context) {
|
|
15275
|
-
var
|
|
15389
|
+
var config = context.config,
|
|
15390
|
+
camera = context.camera,
|
|
15276
15391
|
renderingService = context.renderingService,
|
|
15277
15392
|
renderingContext = context.renderingContext;
|
|
15278
15393
|
var strategies = this.strategies;
|
|
15279
15394
|
renderingService.hooks.cull.tap(CullingPlugin.tag, function (object) {
|
|
15280
15395
|
if (object) {
|
|
15396
|
+
var _config$future;
|
|
15281
15397
|
var cullable = object.cullable;
|
|
15282
15398
|
// cullable.visible = true;
|
|
15283
15399
|
// const renderBounds = object.getRenderBounds();
|
|
@@ -15302,8 +15418,10 @@ var CullingPlugin = /*#__PURE__*/function () {
|
|
|
15302
15418
|
if (!object.isCulled() && object.isVisible()) {
|
|
15303
15419
|
return object;
|
|
15304
15420
|
}
|
|
15421
|
+
var enableCancelEventPropagation = ((_config$future = config.future) === null || _config$future === void 0 ? void 0 : _config$future.experimentalCancelEventPropagation) === true;
|
|
15422
|
+
|
|
15305
15423
|
// if (this.renderingContext.renderListLastFrame.indexOf(object) > -1) {
|
|
15306
|
-
object.dispatchEvent(new CustomEvent(ElementEvent.CULLED));
|
|
15424
|
+
object.dispatchEvent(new CustomEvent(ElementEvent.CULLED), enableCancelEventPropagation, enableCancelEventPropagation);
|
|
15307
15425
|
// }
|
|
15308
15426
|
|
|
15309
15427
|
return null;
|
|
@@ -15718,15 +15836,15 @@ var PrepareRendererPlugin = /*#__PURE__*/function () {
|
|
|
15718
15836
|
key: "apply",
|
|
15719
15837
|
value: function apply(context) {
|
|
15720
15838
|
var _this = this,
|
|
15721
|
-
_runtime$globalThis$r
|
|
15722
|
-
|
|
15839
|
+
_runtime$globalThis$r,
|
|
15840
|
+
_config$future;
|
|
15841
|
+
var config = context.config,
|
|
15842
|
+
renderingService = context.renderingService,
|
|
15723
15843
|
renderingContext = context.renderingContext,
|
|
15724
15844
|
rBushRoot = context.rBushRoot;
|
|
15725
15845
|
var canvas = renderingContext.root.ownerDocument.defaultView;
|
|
15726
15846
|
this.rBush = rBushRoot;
|
|
15727
15847
|
var handleAttributeChanged = function handleAttributeChanged(e) {
|
|
15728
|
-
var object = e.target;
|
|
15729
|
-
object.renderable.dirty = true;
|
|
15730
15848
|
renderingService.dirtify();
|
|
15731
15849
|
};
|
|
15732
15850
|
var handleBoundsChanged = function handleBoundsChanged(e) {
|
|
@@ -15742,11 +15860,11 @@ var PrepareRendererPlugin = /*#__PURE__*/function () {
|
|
|
15742
15860
|
var handleUnmounted = function handleUnmounted(e) {
|
|
15743
15861
|
var object = e.target;
|
|
15744
15862
|
var rBushNode = object.rBushNode;
|
|
15745
|
-
if (rBushNode.aabb) {
|
|
15863
|
+
if (rBushNode !== null && rBushNode !== void 0 && rBushNode.aabb) {
|
|
15746
15864
|
_this.rBush.remove(rBushNode.aabb);
|
|
15747
15865
|
}
|
|
15748
15866
|
_this.syncTasks["delete"](object);
|
|
15749
|
-
runtime.sceneGraphService.
|
|
15867
|
+
runtime.sceneGraphService.dirtyToRoot(object);
|
|
15750
15868
|
renderingService.dirtify();
|
|
15751
15869
|
};
|
|
15752
15870
|
renderingService.hooks.init.tap(PrepareRendererPlugin.tag, function () {
|
|
@@ -15763,6 +15881,7 @@ var PrepareRendererPlugin = /*#__PURE__*/function () {
|
|
|
15763
15881
|
_this.syncTasks.clear();
|
|
15764
15882
|
});
|
|
15765
15883
|
var ric = (_runtime$globalThis$r = runtime.globalThis.requestIdleCallback) !== null && _runtime$globalThis$r !== void 0 ? _runtime$globalThis$r : raf.bind(runtime.globalThis);
|
|
15884
|
+
var enableRICSyncRTree = ((_config$future = config.future) === null || _config$future === void 0 ? void 0 : _config$future.experimentalRICSyncRTree) === true;
|
|
15766
15885
|
renderingService.hooks.endFrame.tap(PrepareRendererPlugin.tag, function () {
|
|
15767
15886
|
if (_this.isFirstTimeRendering) {
|
|
15768
15887
|
_this.isFirstTimeRendering = false;
|
|
@@ -15771,6 +15890,11 @@ var PrepareRendererPlugin = /*#__PURE__*/function () {
|
|
|
15771
15890
|
_this.syncRTree(true);
|
|
15772
15891
|
_this.isFirstTimeRenderingFinished = true;
|
|
15773
15892
|
});
|
|
15893
|
+
} else if (enableRICSyncRTree && runtime.globalThis.requestIdleCallback && runtime.globalThis.cancelIdleCallback) {
|
|
15894
|
+
runtime.globalThis.cancelIdleCallback(_this.ricSyncRTreeId);
|
|
15895
|
+
_this.ricSyncRTreeId = runtime.globalThis.requestIdleCallback(function () {
|
|
15896
|
+
return _this.syncRTree();
|
|
15897
|
+
});
|
|
15774
15898
|
} else {
|
|
15775
15899
|
_this.syncRTree();
|
|
15776
15900
|
}
|
|
@@ -15954,6 +16078,9 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
15954
16078
|
_this.devicePixelRatio = dpr;
|
|
15955
16079
|
_this.requestAnimationFrame = requestAnimationFrame !== null && requestAnimationFrame !== void 0 ? requestAnimationFrame : raf.bind(runtime.globalThis);
|
|
15956
16080
|
_this.cancelAnimationFrame = cancelAnimationFrame !== null && cancelAnimationFrame !== void 0 ? cancelAnimationFrame : caf.bind(runtime.globalThis);
|
|
16081
|
+
_this.createImage = createImage !== null && createImage !== void 0 ? createImage : function () {
|
|
16082
|
+
return new window.Image();
|
|
16083
|
+
};
|
|
15957
16084
|
// the following feature-detect from hammer.js
|
|
15958
16085
|
// @see https://github.com/hammerjs/hammer.js/blob/master/src/inputjs/input-consts.js#L5
|
|
15959
16086
|
_this.supportsTouchEvents = supportsTouchEvents !== null && supportsTouchEvents !== void 0 ? supportsTouchEvents : 'ontouchstart' in runtime.globalThis;
|
|
@@ -15985,14 +16112,12 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
15985
16112
|
devicePixelRatio: dpr,
|
|
15986
16113
|
requestAnimationFrame: _this.requestAnimationFrame,
|
|
15987
16114
|
cancelAnimationFrame: _this.cancelAnimationFrame,
|
|
16115
|
+
createImage: _this.createImage,
|
|
15988
16116
|
supportsTouchEvents: _this.supportsTouchEvents,
|
|
15989
16117
|
supportsPointerEvents: _this.supportsPointerEvents,
|
|
15990
16118
|
isTouchEvent: _this.isTouchEvent,
|
|
15991
16119
|
isMouseEvent: _this.isMouseEvent,
|
|
15992
|
-
dblClickSpeed: dblClickSpeed !== null && dblClickSpeed !== void 0 ? dblClickSpeed : 200
|
|
15993
|
-
createImage: createImage !== null && createImage !== void 0 ? createImage : function () {
|
|
15994
|
-
return new window.Image();
|
|
15995
|
-
}
|
|
16120
|
+
dblClickSpeed: dblClickSpeed !== null && dblClickSpeed !== void 0 ? dblClickSpeed : 200
|
|
15996
16121
|
}));
|
|
15997
16122
|
_this.initDefaultCamera(canvasWidth, canvasHeight, renderer.clipSpaceNearZ);
|
|
15998
16123
|
_this.initRenderer(renderer, true);
|
|
@@ -16010,7 +16135,6 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
16010
16135
|
* the root node in scene graph
|
|
16011
16136
|
*/
|
|
16012
16137
|
root: this.document.documentElement,
|
|
16013
|
-
renderListCurrentFrame: [],
|
|
16014
16138
|
unculledEntities: [],
|
|
16015
16139
|
renderReasons: new Set(),
|
|
16016
16140
|
force: false,
|
|
@@ -16128,11 +16252,13 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
16128
16252
|
}, {
|
|
16129
16253
|
key: "destroy",
|
|
16130
16254
|
value: function destroy() {
|
|
16255
|
+
var _this$getConfig$futur;
|
|
16131
16256
|
var cleanUp = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
16132
16257
|
var skipTriggerEvent = arguments.length > 1 ? arguments[1] : undefined;
|
|
16133
16258
|
memoize.clearCache();
|
|
16259
|
+
var enableCancelEventPropagation = ((_this$getConfig$futur = this.getConfig().future) === null || _this$getConfig$futur === void 0 ? void 0 : _this$getConfig$futur.experimentalCancelEventPropagation) === true;
|
|
16134
16260
|
if (!skipTriggerEvent) {
|
|
16135
|
-
this.dispatchEvent(new CustomEvent(CanvasEvent.BEFORE_DESTROY));
|
|
16261
|
+
this.dispatchEvent(new CustomEvent(CanvasEvent.BEFORE_DESTROY), enableCancelEventPropagation, enableCancelEventPropagation);
|
|
16136
16262
|
}
|
|
16137
16263
|
if (this.frameId) {
|
|
16138
16264
|
this.cancelAnimationFrame(this.frameId);
|
|
@@ -16157,7 +16283,7 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
16157
16283
|
this.context.rBushRoot.clear();
|
|
16158
16284
|
}
|
|
16159
16285
|
if (!skipTriggerEvent) {
|
|
16160
|
-
this.dispatchEvent(new CustomEvent(CanvasEvent.AFTER_DESTROY));
|
|
16286
|
+
this.dispatchEvent(new CustomEvent(CanvasEvent.AFTER_DESTROY), enableCancelEventPropagation, enableCancelEventPropagation);
|
|
16161
16287
|
}
|
|
16162
16288
|
var clearEventRetain = function clearEventRetain(event) {
|
|
16163
16289
|
event.currentTarget = null;
|
|
@@ -16189,6 +16315,7 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
16189
16315
|
}, {
|
|
16190
16316
|
key: "resize",
|
|
16191
16317
|
value: function resize(width, height) {
|
|
16318
|
+
var _canvasConfig$future;
|
|
16192
16319
|
// update canvas' config
|
|
16193
16320
|
var canvasConfig = this.context.config;
|
|
16194
16321
|
canvasConfig.width = width;
|
|
@@ -16206,10 +16333,11 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
16206
16333
|
} else {
|
|
16207
16334
|
camera.setAspect(width / height);
|
|
16208
16335
|
}
|
|
16336
|
+
var enableCancelEventPropagation = ((_canvasConfig$future = canvasConfig.future) === null || _canvasConfig$future === void 0 ? void 0 : _canvasConfig$future.experimentalCancelEventPropagation) === true;
|
|
16209
16337
|
this.dispatchEvent(new CustomEvent(CanvasEvent.RESIZE, {
|
|
16210
16338
|
width: width,
|
|
16211
16339
|
height: height
|
|
16212
|
-
}));
|
|
16340
|
+
}), enableCancelEventPropagation, enableCancelEventPropagation);
|
|
16213
16341
|
}
|
|
16214
16342
|
|
|
16215
16343
|
// proxy to document.documentElement
|
|
@@ -16250,20 +16378,22 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
16250
16378
|
}, {
|
|
16251
16379
|
key: "render",
|
|
16252
16380
|
value: function render(frame) {
|
|
16253
|
-
var
|
|
16381
|
+
var _this$getConfig$futur2,
|
|
16382
|
+
_this4 = this;
|
|
16254
16383
|
// console.log('render ----------------------');
|
|
16255
16384
|
if (frame) {
|
|
16256
16385
|
beforeRenderEvent.detail = frame;
|
|
16257
16386
|
afterRenderEvent.detail = frame;
|
|
16258
16387
|
}
|
|
16259
|
-
this.
|
|
16388
|
+
var enableCancelEventPropagation = ((_this$getConfig$futur2 = this.getConfig().future) === null || _this$getConfig$futur2 === void 0 ? void 0 : _this$getConfig$futur2.experimentalCancelEventPropagation) === true;
|
|
16389
|
+
this.dispatchEvent(beforeRenderEvent, enableCancelEventPropagation, enableCancelEventPropagation);
|
|
16260
16390
|
var renderingService = this.getRenderingService();
|
|
16261
16391
|
renderingService.render(this.getConfig(), frame, function () {
|
|
16262
16392
|
// trigger actual rerender event
|
|
16263
16393
|
// @see https://github.com/antvis/G/issues/1268
|
|
16264
|
-
_this4.dispatchEvent(rerenderEvent);
|
|
16394
|
+
_this4.dispatchEvent(rerenderEvent, enableCancelEventPropagation, enableCancelEventPropagation);
|
|
16265
16395
|
});
|
|
16266
|
-
this.dispatchEvent(afterRenderEvent);
|
|
16396
|
+
this.dispatchEvent(afterRenderEvent, enableCancelEventPropagation, enableCancelEventPropagation);
|
|
16267
16397
|
}
|
|
16268
16398
|
}, {
|
|
16269
16399
|
key: "run",
|
|
@@ -16327,30 +16457,27 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
16327
16457
|
var firstContentfullPaint = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
16328
16458
|
var async = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
16329
16459
|
this.context.renderingService.init(function () {
|
|
16460
|
+
var _this7$getConfig$futu;
|
|
16330
16461
|
_this7.inited = true;
|
|
16462
|
+
var enableCancelEventPropagation = ((_this7$getConfig$futu = _this7.getConfig().future) === null || _this7$getConfig$futu === void 0 ? void 0 : _this7$getConfig$futu.experimentalCancelEventPropagation) === true;
|
|
16331
16463
|
if (firstContentfullPaint) {
|
|
16332
16464
|
if (async) {
|
|
16333
16465
|
_this7.requestAnimationFrame(function () {
|
|
16334
|
-
_this7.dispatchEvent(new CustomEvent(CanvasEvent.READY));
|
|
16466
|
+
_this7.dispatchEvent(new CustomEvent(CanvasEvent.READY), enableCancelEventPropagation, enableCancelEventPropagation);
|
|
16335
16467
|
});
|
|
16336
16468
|
} else {
|
|
16337
|
-
_this7.dispatchEvent(new CustomEvent(CanvasEvent.READY));
|
|
16469
|
+
_this7.dispatchEvent(new CustomEvent(CanvasEvent.READY), enableCancelEventPropagation, enableCancelEventPropagation);
|
|
16338
16470
|
}
|
|
16339
16471
|
} else {
|
|
16340
|
-
_this7.dispatchEvent(new CustomEvent(CanvasEvent.RENDERER_CHANGED));
|
|
16472
|
+
_this7.dispatchEvent(new CustomEvent(CanvasEvent.RENDERER_CHANGED), enableCancelEventPropagation, enableCancelEventPropagation);
|
|
16341
16473
|
}
|
|
16342
16474
|
if (_this7.readyPromise) {
|
|
16343
16475
|
_this7.resolveReadyPromise();
|
|
16344
16476
|
}
|
|
16345
16477
|
if (!firstContentfullPaint) {
|
|
16346
16478
|
_this7.getRoot().forEach(function (node) {
|
|
16347
|
-
var _ref
|
|
16348
|
-
|
|
16349
|
-
if (renderable) {
|
|
16350
|
-
renderable.renderBoundsDirty = true;
|
|
16351
|
-
renderable.boundsDirty = true;
|
|
16352
|
-
renderable.dirty = true;
|
|
16353
|
-
}
|
|
16479
|
+
var _dirty, _ref;
|
|
16480
|
+
(_dirty = (_ref = node).dirty) === null || _dirty === void 0 || _dirty.call(_ref, true, true);
|
|
16354
16481
|
});
|
|
16355
16482
|
}
|
|
16356
16483
|
|
|
@@ -16411,8 +16538,10 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
16411
16538
|
if (parent.isMutationObserved) {
|
|
16412
16539
|
parent.dispatchEvent(unmountedEvent);
|
|
16413
16540
|
} else {
|
|
16541
|
+
var _this$getConfig$futur3;
|
|
16542
|
+
var enableCancelEventPropagation = ((_this$getConfig$futur3 = this.getConfig().future) === null || _this$getConfig$futur3 === void 0 ? void 0 : _this$getConfig$futur3.experimentalCancelEventPropagation) === true;
|
|
16414
16543
|
unmountedEvent.target = parent;
|
|
16415
|
-
this.dispatchEvent(unmountedEvent, true);
|
|
16544
|
+
this.dispatchEvent(unmountedEvent, true, enableCancelEventPropagation);
|
|
16416
16545
|
}
|
|
16417
16546
|
|
|
16418
16547
|
// skip document.documentElement
|
|
@@ -16432,7 +16561,7 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
16432
16561
|
}, {
|
|
16433
16562
|
key: "mountChildren",
|
|
16434
16563
|
value: function mountChildren(child) {
|
|
16435
|
-
var
|
|
16564
|
+
var _this0 = this;
|
|
16436
16565
|
var skipTriggerEvent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : isInFragment(child);
|
|
16437
16566
|
if (this.inited) {
|
|
16438
16567
|
if (!child.isConnected) {
|
|
@@ -16442,8 +16571,10 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
16442
16571
|
if (child.isMutationObserved) {
|
|
16443
16572
|
child.dispatchEvent(mountedEvent);
|
|
16444
16573
|
} else {
|
|
16574
|
+
var _this$getConfig$futur4;
|
|
16575
|
+
var enableCancelEventPropagation = ((_this$getConfig$futur4 = this.getConfig().future) === null || _this$getConfig$futur4 === void 0 ? void 0 : _this$getConfig$futur4.experimentalCancelEventPropagation) === true;
|
|
16445
16576
|
mountedEvent.target = child;
|
|
16446
|
-
this.dispatchEvent(mountedEvent, true);
|
|
16577
|
+
this.dispatchEvent(mountedEvent, true, enableCancelEventPropagation);
|
|
16447
16578
|
}
|
|
16448
16579
|
}
|
|
16449
16580
|
}
|
|
@@ -16453,7 +16584,7 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
16453
16584
|
|
|
16454
16585
|
// recursively mount children
|
|
16455
16586
|
child.childNodes.forEach(function (c) {
|
|
16456
|
-
|
|
16587
|
+
_this0.mountChildren(c, skipTriggerEvent);
|
|
16457
16588
|
});
|
|
16458
16589
|
|
|
16459
16590
|
// trigger after mounted
|
|
@@ -16629,4 +16760,6 @@ exports.runtime = runtime;
|
|
|
16629
16760
|
exports.setDOMSize = setDOMSize;
|
|
16630
16761
|
exports.translatePathToString = translatePathToString;
|
|
16631
16762
|
exports.turn2deg = turn2deg;
|
|
16763
|
+
exports.updateLocalTransform = updateLocalTransform;
|
|
16764
|
+
exports.updateWorldTransform = updateWorldTransform;
|
|
16632
16765
|
//# sourceMappingURL=index.js.map
|