@antv/g-lite 2.2.19 → 2.3.1
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 +742 -614
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +743 -613
- package/dist/index.js.map +1 -1
- package/dist/index.umd.min.js +7 -5
- package/dist/index.umd.min.js.map +1 -1
- package/package.json +1 -1
- 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/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.1
|
|
5
|
+
* @date 7/18/2025, 7:12:41 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
|
/**
|
|
@@ -10480,7 +10559,7 @@ var RenderingService = /*#__PURE__*/function () {
|
|
|
10480
10559
|
// @ts-ignore
|
|
10481
10560
|
renderingContext.dirtyRectangleRenderingDisabled = this.disableDirtyRectangleRendering();
|
|
10482
10561
|
var onlyCameraChanged = renderingContext.renderReasons.size === 1 && renderingContext.renderReasons.has(RenderReason.CAMERA_CHANGED);
|
|
10483
|
-
var shouldTriggerRenderHooks = !canvasConfig.disableRenderHooks || !
|
|
10562
|
+
var shouldTriggerRenderHooks = !canvasConfig.disableRenderHooks || !onlyCameraChanged;
|
|
10484
10563
|
if (shouldTriggerRenderHooks) {
|
|
10485
10564
|
this.renderDisplayObject(renderingContext.root, canvasConfig, renderingContext);
|
|
10486
10565
|
}
|
|
@@ -10497,8 +10576,6 @@ var RenderingService = /*#__PURE__*/function () {
|
|
|
10497
10576
|
renderingContext.renderReasons.clear();
|
|
10498
10577
|
rerenderCallback();
|
|
10499
10578
|
}
|
|
10500
|
-
|
|
10501
|
-
// console.log('stats', this.stats);
|
|
10502
10579
|
}
|
|
10503
10580
|
}, {
|
|
10504
10581
|
key: "renderDisplayObject",
|
|
@@ -10517,14 +10594,15 @@ var RenderingService = /*#__PURE__*/function () {
|
|
|
10517
10594
|
var objectChanged = enableDirtyCheck ?
|
|
10518
10595
|
// @ts-ignore
|
|
10519
10596
|
renderable.dirty || renderingContext.dirtyRectangleRenderingDisabled ? object : null : object;
|
|
10597
|
+
var objectToRender = null;
|
|
10520
10598
|
if (objectChanged) {
|
|
10521
|
-
|
|
10599
|
+
objectToRender = enableCulling ? self.hooks.cull.call(objectChanged, self.context.camera) : objectChanged;
|
|
10522
10600
|
if (objectToRender) {
|
|
10523
10601
|
self.stats.rendered += 1;
|
|
10524
10602
|
renderingContext.renderListCurrentFrame.push(objectToRender);
|
|
10525
10603
|
}
|
|
10526
10604
|
}
|
|
10527
|
-
|
|
10605
|
+
object.dirty(false);
|
|
10528
10606
|
sortable.renderOrder = self.zIndexCounter;
|
|
10529
10607
|
self.zIndexCounter += 1;
|
|
10530
10608
|
self.stats.total += 1;
|
|
@@ -10816,13 +10894,6 @@ MutationEvent.ADDITION = 2;
|
|
|
10816
10894
|
MutationEvent.MODIFICATION = 1;
|
|
10817
10895
|
MutationEvent.REMOVAL = 3;
|
|
10818
10896
|
|
|
10819
|
-
function markRenderableDirty(e) {
|
|
10820
|
-
var renderable = e.renderable;
|
|
10821
|
-
if (renderable) {
|
|
10822
|
-
renderable.renderBoundsDirty = true;
|
|
10823
|
-
renderable.boundsDirty = true;
|
|
10824
|
-
}
|
|
10825
|
-
}
|
|
10826
10897
|
var reparentEvent = new MutationEvent(ElementEvent.REPARENT, null, '', '', '', 0, '', '');
|
|
10827
10898
|
|
|
10828
10899
|
// Object pooling
|
|
@@ -10924,14 +10995,18 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
10924
10995
|
sortable.dirtyReason = SortReason.ADDED;
|
|
10925
10996
|
}
|
|
10926
10997
|
if (isAttachToFragment) return;
|
|
10927
|
-
if (isChildFragment)
|
|
10998
|
+
if (isChildFragment) {
|
|
10999
|
+
this.dirtifyFragment(child);
|
|
11000
|
+
} else {
|
|
10928
11001
|
var transform = child.transformable;
|
|
10929
11002
|
if (transform) {
|
|
10930
|
-
this.
|
|
11003
|
+
this.dirtyWorldTransform(child, transform);
|
|
10931
11004
|
}
|
|
10932
11005
|
}
|
|
10933
11006
|
if (detached) {
|
|
10934
|
-
|
|
11007
|
+
var _parent$ownerDocument;
|
|
11008
|
+
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;
|
|
11009
|
+
child.dispatchEvent(reparentEvent, enableCancelEventPropagation, enableCancelEventPropagation);
|
|
10935
11010
|
}
|
|
10936
11011
|
}
|
|
10937
11012
|
}, {
|
|
@@ -10966,131 +11041,58 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
10966
11041
|
child.parentNode.childNodes.splice(index, 1);
|
|
10967
11042
|
}
|
|
10968
11043
|
if (transform) {
|
|
10969
|
-
this.
|
|
11044
|
+
this.dirtyWorldTransform(child, transform);
|
|
10970
11045
|
}
|
|
10971
11046
|
child.parentNode = null;
|
|
10972
11047
|
}
|
|
11048
|
+
|
|
11049
|
+
// #region local-transform ----------------------------------------------------------------
|
|
10973
11050
|
}, {
|
|
10974
|
-
key: "
|
|
10975
|
-
value: function
|
|
10976
|
-
element.
|
|
10977
|
-
return element.transformable.origin;
|
|
11051
|
+
key: "getLocalPosition",
|
|
11052
|
+
value: function getLocalPosition(element) {
|
|
11053
|
+
return element.transformable.localPosition;
|
|
10978
11054
|
}
|
|
10979
|
-
|
|
10980
|
-
/**
|
|
10981
|
-
* same as pivot in Pixi.js
|
|
10982
|
-
*
|
|
10983
|
-
* @see https://stackoverflow.com/questions/40748452/how-to-change-css-transform-origin-but-preserve-transformation
|
|
10984
|
-
*/
|
|
10985
11055
|
}, {
|
|
10986
|
-
key: "
|
|
10987
|
-
value: function
|
|
10988
|
-
|
|
10989
|
-
var z = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
10990
|
-
if (typeof origin === 'number') {
|
|
10991
|
-
origin = [origin, y, z];
|
|
10992
|
-
}
|
|
10993
|
-
var transform = element.transformable;
|
|
10994
|
-
if (origin[0] === transform.origin[0] && origin[1] === transform.origin[1] && origin[2] === transform.origin[2]) {
|
|
10995
|
-
return;
|
|
10996
|
-
}
|
|
10997
|
-
var originVec = transform.origin;
|
|
10998
|
-
|
|
10999
|
-
// const delta = vec3.subtract(vec3.create(), origin, originVec);
|
|
11000
|
-
// vec3.add(transform.localPosition, transform.localPosition, delta);
|
|
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);
|
|
11056
|
+
key: "getLocalRotation",
|
|
11057
|
+
value: function getLocalRotation(element) {
|
|
11058
|
+
return element.transformable.localRotation;
|
|
11007
11059
|
}
|
|
11008
|
-
|
|
11009
|
-
/**
|
|
11010
|
-
* rotate in world space
|
|
11011
|
-
*/
|
|
11012
11060
|
}, {
|
|
11013
|
-
key: "
|
|
11014
|
-
value: function
|
|
11015
|
-
|
|
11016
|
-
var z = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
11017
|
-
if (typeof degrees === 'number') {
|
|
11018
|
-
degrees = glMatrix.vec3.fromValues(degrees, y, z);
|
|
11019
|
-
}
|
|
11020
|
-
var transform = element.transformable;
|
|
11021
|
-
if (element.parentNode === null || !element.parentNode.transformable) {
|
|
11022
|
-
this.rotateLocal(element, degrees);
|
|
11023
|
-
} else {
|
|
11024
|
-
var rotation = $quat$1;
|
|
11025
|
-
glMatrix.quat.fromEuler(rotation, degrees[0], degrees[1], degrees[2]);
|
|
11026
|
-
var rot = this.getRotation(element);
|
|
11027
|
-
var parentRot = this.getRotation(element.parentNode);
|
|
11028
|
-
glMatrix.quat.copy($rotate_ParentInvertRotation, parentRot);
|
|
11029
|
-
glMatrix.quat.invert($rotate_ParentInvertRotation, $rotate_ParentInvertRotation);
|
|
11030
|
-
glMatrix.quat.multiply(rotation, $rotate_ParentInvertRotation, rotation);
|
|
11031
|
-
glMatrix.quat.multiply(transform.localRotation, rotation, rot);
|
|
11032
|
-
glMatrix.quat.normalize(transform.localRotation, transform.localRotation);
|
|
11033
|
-
this.dirtifyLocal(element, transform);
|
|
11034
|
-
}
|
|
11061
|
+
key: "getLocalScale",
|
|
11062
|
+
value: function getLocalScale(element) {
|
|
11063
|
+
return element.transformable.localScale;
|
|
11035
11064
|
}
|
|
11036
|
-
|
|
11037
|
-
/**
|
|
11038
|
-
* rotate in local space
|
|
11039
|
-
* @see @see https://docs.microsoft.com/en-us/windows/win32/api/directxmath/nf-directxmath-xmquaternionrotationrollpitchyaw
|
|
11040
|
-
*/
|
|
11041
11065
|
}, {
|
|
11042
|
-
key: "
|
|
11043
|
-
value: function
|
|
11044
|
-
|
|
11045
|
-
var z = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
11046
|
-
if (typeof degrees === 'number') {
|
|
11047
|
-
degrees = glMatrix.vec3.fromValues(degrees, y, z);
|
|
11048
|
-
}
|
|
11049
|
-
var transform = element.transformable;
|
|
11050
|
-
glMatrix.quat.fromEuler($rotateLocal, degrees[0], degrees[1], degrees[2]);
|
|
11051
|
-
glMatrix.quat.mul(transform.localRotation, transform.localRotation, $rotateLocal);
|
|
11052
|
-
this.dirtifyLocal(element, transform);
|
|
11066
|
+
key: "getLocalSkew",
|
|
11067
|
+
value: function getLocalSkew(element) {
|
|
11068
|
+
return element.transformable.localSkew;
|
|
11053
11069
|
}
|
|
11054
|
-
|
|
11055
|
-
/**
|
|
11056
|
-
* set euler angles(degrees) in world space
|
|
11057
|
-
*/
|
|
11058
11070
|
}, {
|
|
11059
|
-
key: "
|
|
11060
|
-
value: function
|
|
11061
|
-
var y = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
11062
|
-
var z = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
11063
|
-
if (typeof degrees === 'number') {
|
|
11064
|
-
degrees = glMatrix.vec3.fromValues(degrees, y, z);
|
|
11065
|
-
}
|
|
11071
|
+
key: "getLocalTransform",
|
|
11072
|
+
value: function getLocalTransform(element) {
|
|
11066
11073
|
var transform = element.transformable;
|
|
11067
|
-
|
|
11068
|
-
|
|
11069
|
-
} else {
|
|
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);
|
|
11075
|
-
}
|
|
11074
|
+
updateLocalTransform(transform);
|
|
11075
|
+
return transform.localTransform;
|
|
11076
11076
|
}
|
|
11077
11077
|
|
|
11078
11078
|
/**
|
|
11079
|
-
*
|
|
11079
|
+
* move to position in local space
|
|
11080
11080
|
*/
|
|
11081
11081
|
}, {
|
|
11082
|
-
key: "
|
|
11083
|
-
value: function
|
|
11084
|
-
var
|
|
11085
|
-
var
|
|
11086
|
-
var dirtify = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
|
|
11087
|
-
if (typeof degrees === 'number') {
|
|
11088
|
-
degrees = glMatrix.vec3.fromValues(degrees, y, z);
|
|
11089
|
-
}
|
|
11082
|
+
key: "setLocalPosition",
|
|
11083
|
+
value: function setLocalPosition(element, position) {
|
|
11084
|
+
var _position$;
|
|
11085
|
+
var dirtify = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
11090
11086
|
var transform = element.transformable;
|
|
11091
|
-
|
|
11087
|
+
$setLocalPosition[0] = position[0];
|
|
11088
|
+
$setLocalPosition[1] = position[1];
|
|
11089
|
+
$setLocalPosition[2] = (_position$ = position[2]) !== null && _position$ !== void 0 ? _position$ : 0;
|
|
11090
|
+
if (glMatrix.vec3.equals(transform.localPosition, $setLocalPosition)) {
|
|
11091
|
+
return;
|
|
11092
|
+
}
|
|
11093
|
+
glMatrix.vec3.copy(transform.localPosition, $setLocalPosition);
|
|
11092
11094
|
if (dirtify) {
|
|
11093
|
-
this.
|
|
11095
|
+
this.dirtyLocalTransform(element, transform);
|
|
11094
11096
|
}
|
|
11095
11097
|
}
|
|
11096
11098
|
|
|
@@ -11115,56 +11117,52 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
11115
11117
|
if (glMatrix.vec3.equals(translation, $vec3Zero)) return;
|
|
11116
11118
|
glMatrix.vec3.transformQuat(translation, translation, transform.localRotation);
|
|
11117
11119
|
glMatrix.vec3.add(transform.localPosition, transform.localPosition, translation);
|
|
11118
|
-
this.
|
|
11120
|
+
this.dirtyLocalTransform(element, transform);
|
|
11119
11121
|
}
|
|
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
11122
|
}, {
|
|
11128
|
-
key: "
|
|
11129
|
-
value: function
|
|
11130
|
-
var
|
|
11131
|
-
|
|
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;
|
|
11123
|
+
key: "setLocalRotation",
|
|
11124
|
+
value: function setLocalRotation(element, rotation, y, z, w) {
|
|
11125
|
+
var dirtify = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true;
|
|
11126
|
+
if (typeof rotation === 'number') {
|
|
11127
|
+
rotation = glMatrix.quat.set($quat$1, rotation, y, z, w);
|
|
11137
11128
|
}
|
|
11138
|
-
|
|
11139
|
-
|
|
11140
|
-
|
|
11141
|
-
|
|
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);
|
|
11129
|
+
var transform = element.transformable;
|
|
11130
|
+
glMatrix.quat.copy(transform.localRotation, rotation);
|
|
11131
|
+
if (dirtify) {
|
|
11132
|
+
this.dirtyLocalTransform(element, transform);
|
|
11146
11133
|
}
|
|
11147
|
-
this.dirtifyLocal(element, transform);
|
|
11148
11134
|
}
|
|
11149
11135
|
|
|
11150
11136
|
/**
|
|
11151
|
-
*
|
|
11137
|
+
* rotate in local space
|
|
11138
|
+
* @see @see https://docs.microsoft.com/en-us/windows/win32/api/directxmath/nf-directxmath-xmquaternionrotationrollpitchyaw
|
|
11152
11139
|
*/
|
|
11153
11140
|
}, {
|
|
11154
|
-
key: "
|
|
11155
|
-
value: function
|
|
11156
|
-
var
|
|
11141
|
+
key: "rotateLocal",
|
|
11142
|
+
value: function rotateLocal(element, degrees) {
|
|
11143
|
+
var y = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
11144
|
+
var z = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
11145
|
+
if (typeof degrees === 'number') {
|
|
11146
|
+
degrees = glMatrix.vec3.fromValues(degrees, y, z);
|
|
11147
|
+
}
|
|
11148
|
+
var transform = element.transformable;
|
|
11149
|
+
glMatrix.quat.fromEuler($rotateLocal, degrees[0], degrees[1], degrees[2]);
|
|
11150
|
+
glMatrix.quat.mul(transform.localRotation, transform.localRotation, $rotateLocal);
|
|
11151
|
+
this.dirtyLocalTransform(element, transform);
|
|
11152
|
+
}
|
|
11153
|
+
}, {
|
|
11154
|
+
key: "setLocalScale",
|
|
11155
|
+
value: function setLocalScale(element, scaling) {
|
|
11156
|
+
var _scaling$;
|
|
11157
11157
|
var dirtify = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
11158
11158
|
var transform = element.transformable;
|
|
11159
|
-
$
|
|
11160
|
-
$
|
|
11161
|
-
$setLocalPosition[2] = (_position$2 = position[2]) !== null && _position$2 !== void 0 ? _position$2 : 0;
|
|
11162
|
-
if (glMatrix.vec3.equals(transform.localPosition, $setLocalPosition)) {
|
|
11159
|
+
glMatrix.vec3.set($vec3$1, scaling[0], scaling[1], (_scaling$ = scaling[2]) !== null && _scaling$ !== void 0 ? _scaling$ : transform.localScale[2]);
|
|
11160
|
+
if (glMatrix.vec3.equals($vec3$1, transform.localScale)) {
|
|
11163
11161
|
return;
|
|
11164
11162
|
}
|
|
11165
|
-
glMatrix.vec3.copy(transform.
|
|
11163
|
+
glMatrix.vec3.copy(transform.localScale, $vec3$1);
|
|
11166
11164
|
if (dirtify) {
|
|
11167
|
-
this.
|
|
11165
|
+
this.dirtyLocalTransform(element, transform);
|
|
11168
11166
|
}
|
|
11169
11167
|
}
|
|
11170
11168
|
|
|
@@ -11174,240 +11172,66 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
11174
11172
|
}, {
|
|
11175
11173
|
key: "scaleLocal",
|
|
11176
11174
|
value: function scaleLocal(element, scaling) {
|
|
11177
|
-
var _scaling
|
|
11175
|
+
var _scaling$2;
|
|
11178
11176
|
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.
|
|
11177
|
+
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));
|
|
11178
|
+
this.dirtyLocalTransform(element, transform);
|
|
11181
11179
|
}
|
|
11182
11180
|
}, {
|
|
11183
|
-
key: "
|
|
11184
|
-
value: function
|
|
11185
|
-
var
|
|
11186
|
-
|
|
11187
|
-
|
|
11188
|
-
glMatrix.vec3.set($vec3$1, scaling[0], scaling[1], (_scaling$2 = scaling[2]) !== null && _scaling$2 !== void 0 ? _scaling$2 : transform.localScale[2]);
|
|
11189
|
-
if (glMatrix.vec3.equals($vec3$1, transform.localScale)) {
|
|
11190
|
-
return;
|
|
11181
|
+
key: "setLocalSkew",
|
|
11182
|
+
value: function setLocalSkew(element, skew, y) {
|
|
11183
|
+
var dirtify = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
|
|
11184
|
+
if (typeof skew === 'number') {
|
|
11185
|
+
skew = glMatrix.vec2.set($vec2, skew, y);
|
|
11191
11186
|
}
|
|
11192
|
-
|
|
11187
|
+
var transform = element.transformable;
|
|
11188
|
+
glMatrix.vec2.copy(transform.localSkew, skew);
|
|
11193
11189
|
if (dirtify) {
|
|
11194
|
-
this.
|
|
11190
|
+
this.dirtyLocalTransform(element, transform);
|
|
11195
11191
|
}
|
|
11196
11192
|
}
|
|
11197
11193
|
|
|
11198
11194
|
/**
|
|
11199
|
-
*
|
|
11200
|
-
*
|
|
11201
|
-
* @example
|
|
11202
|
-
* ```
|
|
11203
|
-
* translate(x, y, z)
|
|
11204
|
-
* translate(vec3(x, y, z))
|
|
11205
|
-
* ```
|
|
11206
|
-
*
|
|
11207
|
-
* 对应 g 原版的 translate 2D
|
|
11208
|
-
* @see https://github.com/antvis/g/blob/master/packages/g-base/src/abstract/element.ts#L665-L676
|
|
11195
|
+
* set euler angles(degrees) in local space
|
|
11209
11196
|
*/
|
|
11210
11197
|
}, {
|
|
11211
|
-
key: "
|
|
11212
|
-
value: function
|
|
11198
|
+
key: "setLocalEulerAngles",
|
|
11199
|
+
value: function setLocalEulerAngles(element, degrees) {
|
|
11213
11200
|
var y = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
11214
11201
|
var z = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
11215
|
-
|
|
11216
|
-
|
|
11217
|
-
|
|
11218
|
-
if (glMatrix.vec3.equals(translation, $vec3Zero)) return;
|
|
11219
|
-
glMatrix.vec3.add($vec3$1, this.getPosition(element), translation);
|
|
11220
|
-
this.setPosition(element, $vec3$1);
|
|
11221
|
-
}
|
|
11222
|
-
}, {
|
|
11223
|
-
key: "setRotation",
|
|
11224
|
-
value: function setRotation(element, rotation, y, z, w) {
|
|
11225
|
-
var transform = element.transformable;
|
|
11226
|
-
if (typeof rotation === 'number') {
|
|
11227
|
-
rotation = glMatrix.quat.fromValues(rotation, y, z, w);
|
|
11228
|
-
}
|
|
11229
|
-
if (element.parentNode === null || !element.parentNode.transformable) {
|
|
11230
|
-
this.setLocalRotation(element, rotation);
|
|
11231
|
-
} else {
|
|
11232
|
-
var parentRot = this.getRotation(element.parentNode);
|
|
11233
|
-
glMatrix.quat.copy($quat$1, parentRot);
|
|
11234
|
-
glMatrix.quat.invert($quat$1, $quat$1);
|
|
11235
|
-
glMatrix.quat.multiply(transform.localRotation, $quat$1, rotation);
|
|
11236
|
-
glMatrix.quat.normalize(transform.localRotation, transform.localRotation);
|
|
11237
|
-
this.dirtifyLocal(element, transform);
|
|
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);
|
|
11202
|
+
var dirtify = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
|
|
11203
|
+
if (typeof degrees === 'number') {
|
|
11204
|
+
degrees = glMatrix.vec3.fromValues(degrees, y, z);
|
|
11259
11205
|
}
|
|
11260
11206
|
var transform = element.transformable;
|
|
11261
|
-
glMatrix.
|
|
11207
|
+
glMatrix.quat.fromEuler(transform.localRotation, degrees[0], degrees[1], degrees[2]);
|
|
11262
11208
|
if (dirtify) {
|
|
11263
|
-
this.
|
|
11209
|
+
this.dirtyLocalTransform(element, transform);
|
|
11264
11210
|
}
|
|
11265
11211
|
}
|
|
11266
11212
|
}, {
|
|
11267
|
-
key: "
|
|
11268
|
-
value: function
|
|
11269
|
-
|
|
11270
|
-
|
|
11271
|
-
|
|
11272
|
-
|
|
11273
|
-
|
|
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);
|
|
11307
|
-
}
|
|
11308
|
-
}
|
|
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();
|
|
11213
|
+
key: "setLocalTransform",
|
|
11214
|
+
value: function setLocalTransform(element, transform) {
|
|
11215
|
+
var t = glMatrix.mat4.getTranslation($setLocalTransform_1, transform);
|
|
11216
|
+
var r = glMatrix.mat4.getRotation($setLocalTransform_2, transform);
|
|
11217
|
+
var s = glMatrix.mat4.getScaling($setLocalTransform_3, transform);
|
|
11218
|
+
this.setLocalScale(element, s, false);
|
|
11219
|
+
this.setLocalPosition(element, t, false);
|
|
11220
|
+
this.setLocalRotation(element, r, undefined, undefined, undefined, false);
|
|
11221
|
+
this.dirtyLocalTransform(element, element.transformable);
|
|
11340
11222
|
}
|
|
11341
11223
|
}, {
|
|
11342
|
-
key: "
|
|
11343
|
-
value: function
|
|
11344
|
-
this.
|
|
11224
|
+
key: "resetLocalTransform",
|
|
11225
|
+
value: function resetLocalTransform(element) {
|
|
11226
|
+
this.setLocalScale(element, $vec3One, false);
|
|
11227
|
+
this.setLocalPosition(element, $vec3Zero, false);
|
|
11228
|
+
this.setLocalEulerAngles(element, $vec3Zero, undefined, undefined, false);
|
|
11229
|
+
this.setLocalSkew(element, $vec2Zero, undefined, false);
|
|
11230
|
+
this.dirtyLocalTransform(element, element.transformable);
|
|
11345
11231
|
}
|
|
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
11232
|
|
|
11352
|
-
|
|
11353
|
-
|
|
11354
|
-
p.renderable.dirty = true;
|
|
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
|
-
}
|
|
11391
|
-
}, {
|
|
11392
|
-
key: "informDependentDisplayObjects",
|
|
11393
|
-
value: function informDependentDisplayObjects(object) {
|
|
11394
|
-
var _this2 = this;
|
|
11395
|
-
var dependencyMap = this.displayObjectDependencyMap.get(object);
|
|
11396
|
-
if (!dependencyMap) {
|
|
11397
|
-
return;
|
|
11398
|
-
}
|
|
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
|
-
}
|
|
11233
|
+
// #endregion local-transform
|
|
11234
|
+
// #region transform ----------------------------------------------------------------
|
|
11411
11235
|
}, {
|
|
11412
11236
|
key: "getPosition",
|
|
11413
11237
|
value: function getPosition(element) {
|
|
@@ -11426,6 +11250,12 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
11426
11250
|
var transform = element.transformable;
|
|
11427
11251
|
return glMatrix.mat4.getScaling(transform.scaling, this.getWorldTransform(element, transform));
|
|
11428
11252
|
}
|
|
11253
|
+
}, {
|
|
11254
|
+
key: "getOrigin",
|
|
11255
|
+
value: function getOrigin(element) {
|
|
11256
|
+
element.getGeometryBounds();
|
|
11257
|
+
return element.transformable.origin;
|
|
11258
|
+
}
|
|
11429
11259
|
}, {
|
|
11430
11260
|
key: "getWorldTransform",
|
|
11431
11261
|
value: function getWorldTransform(element) {
|
|
@@ -11436,97 +11266,164 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
11436
11266
|
if (element.parentNode && element.parentNode.transformable) {
|
|
11437
11267
|
this.getWorldTransform(element.parentNode);
|
|
11438
11268
|
}
|
|
11439
|
-
this.
|
|
11269
|
+
this.internalUpdateTransform(element);
|
|
11440
11270
|
return transform.worldTransform;
|
|
11441
11271
|
}
|
|
11272
|
+
|
|
11273
|
+
/**
|
|
11274
|
+
* move to position in world space
|
|
11275
|
+
*
|
|
11276
|
+
* 对应 g 原版的 move/moveTo
|
|
11277
|
+
* @see https://github.com/antvis/g/blob/master/packages/g-base/src/abstract/element.ts#L684-L689
|
|
11278
|
+
*/
|
|
11442
11279
|
}, {
|
|
11443
|
-
key: "
|
|
11444
|
-
value: function
|
|
11445
|
-
|
|
11280
|
+
key: "setPosition",
|
|
11281
|
+
value: function setPosition(element, position) {
|
|
11282
|
+
var _position$2;
|
|
11283
|
+
var transform = element.transformable;
|
|
11284
|
+
$setPosition_1[0] = position[0];
|
|
11285
|
+
$setPosition_1[1] = position[1];
|
|
11286
|
+
$setPosition_1[2] = (_position$2 = position[2]) !== null && _position$2 !== void 0 ? _position$2 : 0;
|
|
11287
|
+
if (glMatrix.vec3.equals(this.getPosition(element), $setPosition_1)) {
|
|
11288
|
+
return;
|
|
11289
|
+
}
|
|
11290
|
+
glMatrix.vec3.copy(transform.position, $setPosition_1);
|
|
11291
|
+
if (element.parentNode === null || !element.parentNode.transformable) {
|
|
11292
|
+
glMatrix.vec3.copy(transform.localPosition, $setPosition_1);
|
|
11293
|
+
} else {
|
|
11294
|
+
var parentTransform = element.parentNode.transformable;
|
|
11295
|
+
glMatrix.mat4.copy($setPosition_ParentInvertMatrix, parentTransform.worldTransform);
|
|
11296
|
+
glMatrix.mat4.invert($setPosition_ParentInvertMatrix, $setPosition_ParentInvertMatrix);
|
|
11297
|
+
glMatrix.vec3.transformMat4(transform.localPosition, $setPosition_1, $setPosition_ParentInvertMatrix);
|
|
11298
|
+
}
|
|
11299
|
+
this.dirtyLocalTransform(element, transform);
|
|
11446
11300
|
}
|
|
11301
|
+
|
|
11302
|
+
/**
|
|
11303
|
+
* translate in world space
|
|
11304
|
+
*
|
|
11305
|
+
* @example
|
|
11306
|
+
* ```
|
|
11307
|
+
* translate(x, y, z)
|
|
11308
|
+
* translate(vec3(x, y, z))
|
|
11309
|
+
* ```
|
|
11310
|
+
*
|
|
11311
|
+
* 对应 g 原版的 translate 2D
|
|
11312
|
+
* @see https://github.com/antvis/g/blob/master/packages/g-base/src/abstract/element.ts#L665-L676
|
|
11313
|
+
*/
|
|
11447
11314
|
}, {
|
|
11448
|
-
key: "
|
|
11449
|
-
value: function
|
|
11450
|
-
|
|
11315
|
+
key: "translate",
|
|
11316
|
+
value: function translate(element, translation) {
|
|
11317
|
+
var y = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
11318
|
+
var z = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
11319
|
+
if (typeof translation === 'number') {
|
|
11320
|
+
translation = glMatrix.vec3.set($vec3$1, translation, y, z);
|
|
11321
|
+
}
|
|
11322
|
+
if (glMatrix.vec3.equals(translation, $vec3Zero)) return;
|
|
11323
|
+
glMatrix.vec3.add($vec3$1, this.getPosition(element), translation);
|
|
11324
|
+
this.setPosition(element, $vec3$1);
|
|
11451
11325
|
}
|
|
11452
11326
|
}, {
|
|
11453
|
-
key: "
|
|
11454
|
-
value: function
|
|
11455
|
-
|
|
11327
|
+
key: "setRotation",
|
|
11328
|
+
value: function setRotation(element, rotation, y, z, w) {
|
|
11329
|
+
var transform = element.transformable;
|
|
11330
|
+
if (typeof rotation === 'number') {
|
|
11331
|
+
rotation = glMatrix.quat.fromValues(rotation, y, z, w);
|
|
11332
|
+
}
|
|
11333
|
+
if (element.parentNode === null || !element.parentNode.transformable) {
|
|
11334
|
+
this.setLocalRotation(element, rotation);
|
|
11335
|
+
} else {
|
|
11336
|
+
var parentRot = this.getRotation(element.parentNode);
|
|
11337
|
+
glMatrix.quat.copy($quat$1, parentRot);
|
|
11338
|
+
glMatrix.quat.invert($quat$1, $quat$1);
|
|
11339
|
+
glMatrix.quat.multiply(transform.localRotation, $quat$1, rotation);
|
|
11340
|
+
glMatrix.quat.normalize(transform.localRotation, transform.localRotation);
|
|
11341
|
+
this.dirtyLocalTransform(element, transform);
|
|
11342
|
+
}
|
|
11456
11343
|
}
|
|
11344
|
+
|
|
11345
|
+
/**
|
|
11346
|
+
* rotate in world space
|
|
11347
|
+
*/
|
|
11457
11348
|
}, {
|
|
11458
|
-
key: "
|
|
11459
|
-
value: function
|
|
11460
|
-
|
|
11349
|
+
key: "rotate",
|
|
11350
|
+
value: function rotate(element, degrees) {
|
|
11351
|
+
var y = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
11352
|
+
var z = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
11353
|
+
if (typeof degrees === 'number') {
|
|
11354
|
+
degrees = glMatrix.vec3.fromValues(degrees, y, z);
|
|
11355
|
+
}
|
|
11356
|
+
var transform = element.transformable;
|
|
11357
|
+
if (element.parentNode === null || !element.parentNode.transformable) {
|
|
11358
|
+
this.rotateLocal(element, degrees);
|
|
11359
|
+
} else {
|
|
11360
|
+
var rotation = $quat$1;
|
|
11361
|
+
glMatrix.quat.fromEuler(rotation, degrees[0], degrees[1], degrees[2]);
|
|
11362
|
+
var rot = this.getRotation(element);
|
|
11363
|
+
var parentRot = this.getRotation(element.parentNode);
|
|
11364
|
+
glMatrix.quat.copy($rotate_ParentInvertRotation, parentRot);
|
|
11365
|
+
glMatrix.quat.invert($rotate_ParentInvertRotation, $rotate_ParentInvertRotation);
|
|
11366
|
+
glMatrix.quat.multiply(rotation, $rotate_ParentInvertRotation, rotation);
|
|
11367
|
+
glMatrix.quat.multiply(transform.localRotation, rotation, rot);
|
|
11368
|
+
glMatrix.quat.normalize(transform.localRotation, transform.localRotation);
|
|
11369
|
+
this.dirtyLocalTransform(element, transform);
|
|
11370
|
+
}
|
|
11461
11371
|
}
|
|
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
11372
|
|
|
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
|
-
}
|
|
11373
|
+
/**
|
|
11374
|
+
* same as pivot in Pixi.js
|
|
11375
|
+
*
|
|
11376
|
+
* @see https://stackoverflow.com/questions/40748452/how-to-change-css-transform-origin-but-preserve-transformation
|
|
11377
|
+
*/
|
|
11378
|
+
}, {
|
|
11379
|
+
key: "setOrigin",
|
|
11380
|
+
value: function setOrigin(element, origin) {
|
|
11381
|
+
var y = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
11382
|
+
var z = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
11383
|
+
if (typeof origin === 'number') {
|
|
11384
|
+
origin = [origin, y, z];
|
|
11498
11385
|
}
|
|
11386
|
+
var transform = element.transformable;
|
|
11387
|
+
if (origin[0] === transform.origin[0] && origin[1] === transform.origin[1] && origin[2] === transform.origin[2]) {
|
|
11388
|
+
return;
|
|
11389
|
+
}
|
|
11390
|
+
var originVec = transform.origin;
|
|
11391
|
+
|
|
11392
|
+
// const delta = vec3.subtract(vec3.create(), origin, originVec);
|
|
11393
|
+
// vec3.add(transform.localPosition, transform.localPosition, delta);
|
|
11394
|
+
|
|
11395
|
+
// update origin
|
|
11396
|
+
originVec[0] = origin[0];
|
|
11397
|
+
originVec[1] = origin[1];
|
|
11398
|
+
originVec[2] = origin[2] || 0;
|
|
11399
|
+
this.dirtyLocalTransform(element, transform);
|
|
11499
11400
|
}
|
|
11401
|
+
|
|
11402
|
+
/**
|
|
11403
|
+
* set euler angles(degrees) in world space
|
|
11404
|
+
*/
|
|
11500
11405
|
}, {
|
|
11501
|
-
key: "
|
|
11502
|
-
value: function
|
|
11406
|
+
key: "setEulerAngles",
|
|
11407
|
+
value: function setEulerAngles(element, degrees) {
|
|
11408
|
+
var y = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
11409
|
+
var z = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
11410
|
+
if (typeof degrees === 'number') {
|
|
11411
|
+
degrees = glMatrix.vec3.fromValues(degrees, y, z);
|
|
11412
|
+
}
|
|
11503
11413
|
var transform = element.transformable;
|
|
11504
|
-
if (
|
|
11505
|
-
this.
|
|
11506
|
-
|
|
11414
|
+
if (element.parentNode === null || !element.parentNode.transformable) {
|
|
11415
|
+
this.setLocalEulerAngles(element, degrees);
|
|
11416
|
+
} else {
|
|
11417
|
+
glMatrix.quat.fromEuler(transform.localRotation, degrees[0], degrees[1], degrees[2]);
|
|
11418
|
+
var parentRotation = this.getRotation(element.parentNode);
|
|
11419
|
+
glMatrix.quat.copy($setEulerAngles_InvParentRot, glMatrix.quat.invert($quat$1, parentRotation));
|
|
11420
|
+
glMatrix.quat.mul(transform.localRotation, transform.localRotation, $setEulerAngles_InvParentRot);
|
|
11421
|
+
this.dirtyLocalTransform(element, transform);
|
|
11507
11422
|
}
|
|
11508
|
-
return transform.localTransform;
|
|
11509
|
-
}
|
|
11510
|
-
}, {
|
|
11511
|
-
key: "setLocalTransform",
|
|
11512
|
-
value: function setLocalTransform(element, transform) {
|
|
11513
|
-
var t = glMatrix.mat4.getTranslation($setLocalTransform_1, transform);
|
|
11514
|
-
var r = glMatrix.mat4.getRotation($setLocalTransform_2, transform);
|
|
11515
|
-
var s = glMatrix.mat4.getScaling($setLocalTransform_3, transform);
|
|
11516
|
-
this.setLocalScale(element, s, false);
|
|
11517
|
-
this.setLocalPosition(element, t, false);
|
|
11518
|
-
this.setLocalRotation(element, r, undefined, undefined, undefined, false);
|
|
11519
|
-
this.dirtifyLocal(element, element.transformable);
|
|
11520
|
-
}
|
|
11521
|
-
}, {
|
|
11522
|
-
key: "resetLocalTransform",
|
|
11523
|
-
value: function resetLocalTransform(element) {
|
|
11524
|
-
this.setLocalScale(element, $vec3One, false);
|
|
11525
|
-
this.setLocalPosition(element, $vec3Zero, false);
|
|
11526
|
-
this.setLocalEulerAngles(element, $vec3Zero, undefined, undefined, false);
|
|
11527
|
-
this.setLocalSkew(element, $vec2Zero, undefined, false);
|
|
11528
|
-
this.dirtifyLocal(element, element.transformable);
|
|
11529
11423
|
}
|
|
11424
|
+
|
|
11425
|
+
// #endregion transform
|
|
11426
|
+
// #region bbox ----------------------------------------------------------------
|
|
11530
11427
|
}, {
|
|
11531
11428
|
key: "getTransformedGeometryBounds",
|
|
11532
11429
|
value: function getTransformedGeometryBounds(element) {
|
|
@@ -11564,7 +11461,7 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
11564
11461
|
}, {
|
|
11565
11462
|
key: "getBounds",
|
|
11566
11463
|
value: function getBounds(element) {
|
|
11567
|
-
var
|
|
11464
|
+
var _this = this;
|
|
11568
11465
|
var render = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
11569
11466
|
var _ref4 = element,
|
|
11570
11467
|
renderable = _ref4.renderable;
|
|
@@ -11584,7 +11481,7 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
11584
11481
|
// merge children's aabbs
|
|
11585
11482
|
var children = element.childNodes;
|
|
11586
11483
|
children.forEach(function (child) {
|
|
11587
|
-
var childBounds =
|
|
11484
|
+
var childBounds = _this.getBounds(child, render);
|
|
11588
11485
|
if (childBounds) {
|
|
11589
11486
|
if (!aabb) {
|
|
11590
11487
|
aabb = existedAABB || new AABB();
|
|
@@ -11667,75 +11564,258 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
11667
11564
|
}
|
|
11668
11565
|
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
11566
|
}
|
|
11567
|
+
|
|
11568
|
+
// #endregion bbox
|
|
11569
|
+
// #region other ----------------------------------------------------------------
|
|
11570
|
+
}, {
|
|
11571
|
+
key: "internalUpdateTransform",
|
|
11572
|
+
value: function internalUpdateTransform(element) {
|
|
11573
|
+
var _element$parentNode;
|
|
11574
|
+
var parentTransform = (_element$parentNode = element.parentNode) === null || _element$parentNode === void 0 ? void 0 : _element$parentNode.transformable;
|
|
11575
|
+
updateLocalTransform(element.transformable);
|
|
11576
|
+
updateWorldTransform(element.transformable, parentTransform);
|
|
11577
|
+
}
|
|
11578
|
+
}, {
|
|
11579
|
+
key: "internalUpdateElement",
|
|
11580
|
+
value: function internalUpdateElement(element, ancestors) {
|
|
11581
|
+
var _element$ownerDocumen2, _element$transformabl, _element$renderable, _element$renderable2;
|
|
11582
|
+
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;
|
|
11583
|
+
var parent = ancestors[ancestors.length - 1];
|
|
11584
|
+
// parent nodes affect child nodes
|
|
11585
|
+
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);
|
|
11586
|
+
if (element.transformable) {
|
|
11587
|
+
var _element$transformabl2;
|
|
11588
|
+
(_element$transformabl2 = element.transformable).dirtyFlag || (_element$transformabl2.dirtyFlag = transformDirty);
|
|
11589
|
+
}
|
|
11590
|
+
this.internalUpdateTransform(element);
|
|
11591
|
+
if (transformDirty) {
|
|
11592
|
+
var _element$dirty;
|
|
11593
|
+
(_element$dirty = element.dirty) === null || _element$dirty === void 0 || _element$dirty.call(element, true, true);
|
|
11594
|
+
}
|
|
11595
|
+
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);
|
|
11596
|
+
|
|
11597
|
+
// The transformation matrix of the child node changes,
|
|
11598
|
+
// which will cause the bounding box data of the ancestor node to become outdated.
|
|
11599
|
+
if ((transformDirty || shapeUpdated) && (parent === null || parent === void 0 ? void 0 : parent.shapeUpdated) === false && enableAttributeUpdateOptimization) {
|
|
11600
|
+
var tempElIndex = ancestors.length - 1;
|
|
11601
|
+
while (tempElIndex >= 0) {
|
|
11602
|
+
var _dirty, _ref5;
|
|
11603
|
+
var tempEl = ancestors[tempElIndex];
|
|
11604
|
+
if (tempEl.shapeUpdated) {
|
|
11605
|
+
break;
|
|
11606
|
+
}
|
|
11607
|
+
(_dirty = (_ref5 = tempEl.node).dirty) === null || _dirty === void 0 || _dirty.call(_ref5, true, true);
|
|
11608
|
+
tempEl.shapeUpdated = true;
|
|
11609
|
+
tempElIndex -= 1;
|
|
11610
|
+
}
|
|
11611
|
+
}
|
|
11612
|
+
return transformDirty;
|
|
11613
|
+
}
|
|
11614
|
+
}, {
|
|
11615
|
+
key: "syncHierarchy",
|
|
11616
|
+
value: function syncHierarchy(rootNode) {
|
|
11617
|
+
var _transformable, _transformable2;
|
|
11618
|
+
// console.log('syncHierarchy');
|
|
11619
|
+
var stack = [rootNode];
|
|
11620
|
+
var ancestors = rootNode.parentNode ? [{
|
|
11621
|
+
node: rootNode.parentNode,
|
|
11622
|
+
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),
|
|
11623
|
+
shapeUpdated: false
|
|
11624
|
+
}] : [];
|
|
11625
|
+
while (stack.length > 0) {
|
|
11626
|
+
var node = stack.pop();
|
|
11627
|
+
var parent = ancestors[ancestors.length - 1];
|
|
11628
|
+
while (ancestors.length > 0 && node.parentNode !== parent.node) {
|
|
11629
|
+
parent = ancestors.pop();
|
|
11630
|
+
}
|
|
11631
|
+
var transformDirty = this.internalUpdateElement(node, ancestors);
|
|
11632
|
+
if (node.childNodes.length > 0) {
|
|
11633
|
+
for (var i = node.childNodes.length - 1; i >= 0; i--) {
|
|
11634
|
+
stack.push(node.childNodes[i]);
|
|
11635
|
+
}
|
|
11636
|
+
ancestors.push({
|
|
11637
|
+
node: node,
|
|
11638
|
+
transformDirty: transformDirty,
|
|
11639
|
+
shapeUpdated: false
|
|
11640
|
+
});
|
|
11641
|
+
}
|
|
11642
|
+
}
|
|
11643
|
+
}
|
|
11644
|
+
}, {
|
|
11645
|
+
key: "dirtyLocalTransform",
|
|
11646
|
+
value: function dirtyLocalTransform(element, transform) {
|
|
11647
|
+
if (isInFragment(element)) return;
|
|
11648
|
+
if (!transform.localDirtyFlag) {
|
|
11649
|
+
transform.localDirtyFlag = true;
|
|
11650
|
+
if (!transform.dirtyFlag) {
|
|
11651
|
+
this.dirtyWorldTransform(element, transform);
|
|
11652
|
+
}
|
|
11653
|
+
}
|
|
11654
|
+
}
|
|
11655
|
+
}, {
|
|
11656
|
+
key: "dirtyWorldTransform",
|
|
11657
|
+
value: function dirtyWorldTransform(element, transform) {
|
|
11658
|
+
this.dirtifyWorldInternal(element, transform);
|
|
11659
|
+
this.dirtyToRoot(element, true);
|
|
11660
|
+
}
|
|
11670
11661
|
}, {
|
|
11671
11662
|
key: "dirtifyWorldInternal",
|
|
11672
11663
|
value: function dirtifyWorldInternal(element, transform) {
|
|
11673
|
-
var
|
|
11664
|
+
var _element$ownerDocumen3,
|
|
11665
|
+
_this2 = this;
|
|
11666
|
+
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
11667
|
if (!transform.dirtyFlag) {
|
|
11675
11668
|
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;
|
|
11669
|
+
element.dirty(true, true);
|
|
11670
|
+
if (!enableAttributeUpdateOptimization) {
|
|
11671
|
+
element.childNodes.forEach(function (child) {
|
|
11672
|
+
var childTransform = child.transformable;
|
|
11673
|
+
_this2.dirtifyWorldInternal(child, childTransform);
|
|
11674
|
+
});
|
|
11689
11675
|
}
|
|
11690
11676
|
}
|
|
11691
11677
|
}
|
|
11692
11678
|
}, {
|
|
11693
|
-
key: "
|
|
11694
|
-
value: function
|
|
11679
|
+
key: "dirtyToRoot",
|
|
11680
|
+
value: function dirtyToRoot(element) {
|
|
11681
|
+
var _element$ownerDocumen4;
|
|
11682
|
+
var affectChildren = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
11683
|
+
var p = element;
|
|
11684
|
+
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;
|
|
11685
|
+
while (p) {
|
|
11686
|
+
var _dirty2, _ref6;
|
|
11687
|
+
(_dirty2 = (_ref6 = p).dirty) === null || _dirty2 === void 0 || _dirty2.call(_ref6, true, true);
|
|
11688
|
+
if (enableAttributeUpdateOptimization) {
|
|
11689
|
+
break;
|
|
11690
|
+
} else {
|
|
11691
|
+
p = p.parentNode;
|
|
11692
|
+
}
|
|
11693
|
+
}
|
|
11694
|
+
if (affectChildren) {
|
|
11695
|
+
element.forEach(function (e) {
|
|
11696
|
+
var _e$dirty;
|
|
11697
|
+
(_e$dirty = e.dirty) === null || _e$dirty === void 0 || _e$dirty.call(e, true, true);
|
|
11698
|
+
});
|
|
11699
|
+
}
|
|
11700
|
+
this.informDependentDisplayObjects(element);
|
|
11701
|
+
this.pendingEvents.set(element, affectChildren);
|
|
11702
|
+
}
|
|
11703
|
+
}, {
|
|
11704
|
+
key: "dirtifyFragment",
|
|
11705
|
+
value: function dirtifyFragment(element) {
|
|
11706
|
+
var _dirty3, _ref7;
|
|
11695
11707
|
var transform = element.transformable;
|
|
11696
|
-
if (transform
|
|
11697
|
-
|
|
11708
|
+
if (transform) {
|
|
11709
|
+
transform.dirtyFlag = true;
|
|
11710
|
+
transform.localDirtyFlag = true;
|
|
11698
11711
|
}
|
|
11699
|
-
|
|
11700
|
-
|
|
11701
|
-
|
|
11712
|
+
(_dirty3 = (_ref7 = element).dirty) === null || _dirty3 === void 0 || _dirty3.call(_ref7, true, true);
|
|
11713
|
+
var length = element.childNodes.length;
|
|
11714
|
+
for (var i = 0; i < length; i++) {
|
|
11715
|
+
this.dirtifyFragment(element.childNodes[i]);
|
|
11702
11716
|
}
|
|
11703
|
-
|
|
11704
|
-
|
|
11705
|
-
this.syncHierarchy(children[i]);
|
|
11717
|
+
if (element.nodeName === Shape.FRAGMENT) {
|
|
11718
|
+
this.pendingEvents.set(element, false);
|
|
11706
11719
|
}
|
|
11707
11720
|
}
|
|
11708
11721
|
}, {
|
|
11709
|
-
key: "
|
|
11710
|
-
value: function
|
|
11711
|
-
|
|
11712
|
-
|
|
11713
|
-
|
|
11714
|
-
|
|
11715
|
-
|
|
11716
|
-
|
|
11717
|
-
|
|
11718
|
-
|
|
11719
|
-
|
|
11722
|
+
key: "triggerPendingEvents",
|
|
11723
|
+
value: function triggerPendingEvents() {
|
|
11724
|
+
var _this3 = this;
|
|
11725
|
+
var triggered = new Set();
|
|
11726
|
+
var enableCancelEventPropagation;
|
|
11727
|
+
var enableAttributeUpdateOptimization;
|
|
11728
|
+
var trigger = function trigger(element, detail) {
|
|
11729
|
+
if (!element.isConnected || triggered.has(element) || element.nodeName === Shape.FRAGMENT) {
|
|
11730
|
+
return;
|
|
11731
|
+
}
|
|
11732
|
+
_this3.boundsChangedEvent.detail = detail;
|
|
11733
|
+
_this3.boundsChangedEvent.target = element;
|
|
11734
|
+
if (element.isMutationObserved) {
|
|
11735
|
+
element.dispatchEvent(_this3.boundsChangedEvent);
|
|
11720
11736
|
} else {
|
|
11721
|
-
|
|
11722
|
-
|
|
11723
|
-
|
|
11737
|
+
if (enableCancelEventPropagation === undefined) {
|
|
11738
|
+
var _element$ownerDocumen5;
|
|
11739
|
+
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;
|
|
11740
|
+
}
|
|
11741
|
+
element.ownerDocument.defaultView.dispatchEvent(_this3.boundsChangedEvent, true, enableCancelEventPropagation);
|
|
11724
11742
|
}
|
|
11725
|
-
|
|
11726
|
-
}
|
|
11743
|
+
triggered.add(element);
|
|
11744
|
+
};
|
|
11745
|
+
this.pendingEvents.forEach(function (affectChildren, element) {
|
|
11746
|
+
if (element.nodeName === Shape.FRAGMENT) {
|
|
11747
|
+
return;
|
|
11748
|
+
}
|
|
11749
|
+
if (enableAttributeUpdateOptimization === undefined) {
|
|
11750
|
+
var _element$ownerDocumen6;
|
|
11751
|
+
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;
|
|
11752
|
+
}
|
|
11753
|
+
$triggerPendingEvents_detail.affectChildren = affectChildren;
|
|
11754
|
+
if (enableAttributeUpdateOptimization) {
|
|
11755
|
+
trigger(element, $triggerPendingEvents_detail);
|
|
11756
|
+
} else {
|
|
11757
|
+
// eslint-disable-next-line no-lonely-if
|
|
11758
|
+
if (affectChildren) {
|
|
11759
|
+
element.forEach(function (e) {
|
|
11760
|
+
trigger(e, $triggerPendingEvents_detail);
|
|
11761
|
+
});
|
|
11762
|
+
} else {
|
|
11763
|
+
trigger(element, $triggerPendingEvents_detail);
|
|
11764
|
+
}
|
|
11765
|
+
}
|
|
11766
|
+
});
|
|
11767
|
+
triggered.clear();
|
|
11768
|
+
this.clearPendingEvents();
|
|
11727
11769
|
}
|
|
11728
11770
|
}, {
|
|
11729
|
-
key: "
|
|
11730
|
-
value: function
|
|
11731
|
-
|
|
11732
|
-
|
|
11733
|
-
|
|
11734
|
-
|
|
11735
|
-
|
|
11771
|
+
key: "clearPendingEvents",
|
|
11772
|
+
value: function clearPendingEvents() {
|
|
11773
|
+
this.pendingEvents.clear();
|
|
11774
|
+
}
|
|
11775
|
+
}, {
|
|
11776
|
+
key: "updateDisplayObjectDependency",
|
|
11777
|
+
value: function updateDisplayObjectDependency(name, oldPath, newPath, object) {
|
|
11778
|
+
// clear ref to old clip path
|
|
11779
|
+
if (oldPath && oldPath !== newPath) {
|
|
11780
|
+
var oldDependencyMap = this.displayObjectDependencyMap.get(oldPath);
|
|
11781
|
+
if (oldDependencyMap && oldDependencyMap[name]) {
|
|
11782
|
+
var index = oldDependencyMap[name].indexOf(object);
|
|
11783
|
+
oldDependencyMap[name].splice(index, 1);
|
|
11784
|
+
}
|
|
11785
|
+
}
|
|
11786
|
+
if (newPath) {
|
|
11787
|
+
var newDependencyMap = this.displayObjectDependencyMap.get(newPath);
|
|
11788
|
+
if (!newDependencyMap) {
|
|
11789
|
+
this.displayObjectDependencyMap.set(newPath, {});
|
|
11790
|
+
newDependencyMap = this.displayObjectDependencyMap.get(newPath);
|
|
11791
|
+
}
|
|
11792
|
+
if (!newDependencyMap[name]) {
|
|
11793
|
+
newDependencyMap[name] = [];
|
|
11736
11794
|
}
|
|
11737
|
-
|
|
11795
|
+
newDependencyMap[name].push(object);
|
|
11796
|
+
}
|
|
11797
|
+
}
|
|
11798
|
+
}, {
|
|
11799
|
+
key: "informDependentDisplayObjects",
|
|
11800
|
+
value: function informDependentDisplayObjects(object) {
|
|
11801
|
+
var _object$ownerDocument,
|
|
11802
|
+
_this4 = this;
|
|
11803
|
+
var dependencyMap = this.displayObjectDependencyMap.get(object);
|
|
11804
|
+
if (!dependencyMap) {
|
|
11805
|
+
return;
|
|
11738
11806
|
}
|
|
11807
|
+
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;
|
|
11808
|
+
Object.keys(dependencyMap).forEach(function (name) {
|
|
11809
|
+
dependencyMap[name].forEach(function (target) {
|
|
11810
|
+
_this4.dirtyToRoot(target, true);
|
|
11811
|
+
target.dispatchEvent(new MutationEvent(ElementEvent.ATTR_MODIFIED, target, _this4, _this4, name, MutationEvent.MODIFICATION, _this4, _this4), enableCancelEventPropagation, enableCancelEventPropagation);
|
|
11812
|
+
if (target.isCustomElement && target.isConnected) {
|
|
11813
|
+
if (target.attributeChangedCallback) {
|
|
11814
|
+
target.attributeChangedCallback(name, _this4, _this4);
|
|
11815
|
+
}
|
|
11816
|
+
}
|
|
11817
|
+
});
|
|
11818
|
+
});
|
|
11739
11819
|
}
|
|
11740
11820
|
}]);
|
|
11741
11821
|
}();
|
|
@@ -12026,6 +12106,10 @@ var TextService = /*#__PURE__*/function () {
|
|
|
12026
12106
|
key: "wordWrap",
|
|
12027
12107
|
value: function wordWrap(text, parsedStyle, offscreenCanvas) {
|
|
12028
12108
|
var _this2 = this;
|
|
12109
|
+
var chars = Array.from(text);
|
|
12110
|
+
if (chars.length === 0) {
|
|
12111
|
+
return '';
|
|
12112
|
+
}
|
|
12029
12113
|
var self = this;
|
|
12030
12114
|
var _parsedStyle$wordWrap2 = parsedStyle.wordWrapWidth,
|
|
12031
12115
|
wordWrapWidth = _parsedStyle$wordWrap2 === void 0 ? 0 : _parsedStyle$wordWrap2,
|
|
@@ -12042,8 +12126,7 @@ var TextService = /*#__PURE__*/function () {
|
|
|
12042
12126
|
} else if (textOverflow && textOverflow !== 'clip') {
|
|
12043
12127
|
ellipsis = textOverflow;
|
|
12044
12128
|
}
|
|
12045
|
-
var
|
|
12046
|
-
var lines = [];
|
|
12129
|
+
var lines = [''];
|
|
12047
12130
|
var currentLineIndex = 0;
|
|
12048
12131
|
var currentLineWidth = 0;
|
|
12049
12132
|
// @see https://github.com/antvis/G/issues/1932
|
|
@@ -12103,10 +12186,10 @@ var TextService = /*#__PURE__*/function () {
|
|
|
12103
12186
|
if (this.isNewline(_char2)) {
|
|
12104
12187
|
// exceed maxLines, break immediately
|
|
12105
12188
|
if (currentLineIndex + 1 >= maxLines) {
|
|
12106
|
-
parsedStyle.isOverflowing = true;
|
|
12107
12189
|
if (i < chars.length - 1) {
|
|
12108
12190
|
appendEllipsis(currentLineIndex, i - 1);
|
|
12109
12191
|
}
|
|
12192
|
+
parsedStyle.isOverflowing = true;
|
|
12110
12193
|
break;
|
|
12111
12194
|
}
|
|
12112
12195
|
prevLineLastCharIndex = i - 1;
|
|
@@ -12115,6 +12198,13 @@ var TextService = /*#__PURE__*/function () {
|
|
|
12115
12198
|
lines[currentLineIndex] = '';
|
|
12116
12199
|
continue;
|
|
12117
12200
|
}
|
|
12201
|
+
|
|
12202
|
+
// If char width exceeds max width, no need to continue
|
|
12203
|
+
if (charWidth > maxWidth) {
|
|
12204
|
+
appendEllipsis(currentLineIndex, i - 1);
|
|
12205
|
+
parsedStyle.isOverflowing = true;
|
|
12206
|
+
break;
|
|
12207
|
+
}
|
|
12118
12208
|
if (currentLineWidth > 0 && currentLineWidth + charWidth > maxWidth) {
|
|
12119
12209
|
var result = findCharIndexClosestWidthThreshold(lines[currentLineIndex], i - 1, prevLineLastCharIndex + 1, maxWidth);
|
|
12120
12210
|
if (result.txtLastCharIndex !== i - 1) {
|
|
@@ -12129,8 +12219,8 @@ var TextService = /*#__PURE__*/function () {
|
|
|
12129
12219
|
charWidth = calcWidth(_char2);
|
|
12130
12220
|
}
|
|
12131
12221
|
if (currentLineIndex + 1 >= maxLines) {
|
|
12132
|
-
parsedStyle.isOverflowing = true;
|
|
12133
12222
|
appendEllipsis(currentLineIndex, i - 1);
|
|
12223
|
+
parsedStyle.isOverflowing = true;
|
|
12134
12224
|
break;
|
|
12135
12225
|
}
|
|
12136
12226
|
prevLineLastCharIndex = i - 1;
|
|
@@ -12150,7 +12240,7 @@ var TextService = /*#__PURE__*/function () {
|
|
|
12150
12240
|
}
|
|
12151
12241
|
}
|
|
12152
12242
|
currentLineWidth += charWidth;
|
|
12153
|
-
lines[currentLineIndex]
|
|
12243
|
+
lines[currentLineIndex] += _char2;
|
|
12154
12244
|
}
|
|
12155
12245
|
return lines.join('\n');
|
|
12156
12246
|
}
|
|
@@ -12296,24 +12386,9 @@ var Element = /*#__PURE__*/function (_Node) {
|
|
|
12296
12386
|
* Unique id.
|
|
12297
12387
|
*/
|
|
12298
12388
|
_this.entity = entityCounter++;
|
|
12299
|
-
_this.renderable = {
|
|
12300
|
-
bounds: undefined,
|
|
12301
|
-
boundsDirty: true,
|
|
12302
|
-
renderBounds: undefined,
|
|
12303
|
-
renderBoundsDirty: true,
|
|
12304
|
-
dirtyRenderBounds: undefined,
|
|
12305
|
-
dirty: false
|
|
12306
|
-
};
|
|
12307
|
-
_this.cullable = {
|
|
12308
|
-
strategy: Strategy.Standard,
|
|
12309
|
-
visibilityPlaneMask: -1,
|
|
12310
|
-
visible: true,
|
|
12311
|
-
enable: true
|
|
12312
|
-
};
|
|
12313
12389
|
_this.transformable = {
|
|
12314
12390
|
dirtyFlag: false,
|
|
12315
12391
|
localDirtyFlag: false,
|
|
12316
|
-
frozen: false,
|
|
12317
12392
|
localPosition: [0, 0, 0],
|
|
12318
12393
|
localRotation: [0, 0, 0, 1],
|
|
12319
12394
|
localScale: [1, 1, 1],
|
|
@@ -12325,6 +12400,25 @@ var Element = /*#__PURE__*/function (_Node) {
|
|
|
12325
12400
|
worldTransform: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],
|
|
12326
12401
|
origin: [0, 0, 0]
|
|
12327
12402
|
};
|
|
12403
|
+
_this.renderable = {
|
|
12404
|
+
bounds: undefined,
|
|
12405
|
+
boundsDirty: true,
|
|
12406
|
+
renderBounds: undefined,
|
|
12407
|
+
renderBoundsDirty: true,
|
|
12408
|
+
dirtyRenderBounds: undefined,
|
|
12409
|
+
dirty: false
|
|
12410
|
+
};
|
|
12411
|
+
_this.geometry = {
|
|
12412
|
+
contentBounds: undefined,
|
|
12413
|
+
renderBounds: undefined,
|
|
12414
|
+
dirty: true
|
|
12415
|
+
};
|
|
12416
|
+
_this.cullable = {
|
|
12417
|
+
strategy: Strategy.Standard,
|
|
12418
|
+
visibilityPlaneMask: -1,
|
|
12419
|
+
visible: true,
|
|
12420
|
+
enable: true
|
|
12421
|
+
};
|
|
12328
12422
|
_this.sortable = {
|
|
12329
12423
|
dirty: false,
|
|
12330
12424
|
sorted: undefined,
|
|
@@ -12332,11 +12426,6 @@ var Element = /*#__PURE__*/function (_Node) {
|
|
|
12332
12426
|
dirtyChildren: [],
|
|
12333
12427
|
dirtyReason: undefined
|
|
12334
12428
|
};
|
|
12335
|
-
_this.geometry = {
|
|
12336
|
-
contentBounds: undefined,
|
|
12337
|
-
renderBounds: undefined,
|
|
12338
|
-
dirty: true
|
|
12339
|
-
};
|
|
12340
12429
|
_this.rBushNode = {
|
|
12341
12430
|
aabb: undefined
|
|
12342
12431
|
};
|
|
@@ -12352,10 +12441,6 @@ var Element = /*#__PURE__*/function (_Node) {
|
|
|
12352
12441
|
*/
|
|
12353
12442
|
_this.clientTop = 0;
|
|
12354
12443
|
_this.clientLeft = 0;
|
|
12355
|
-
/**
|
|
12356
|
-
* is destroyed or not
|
|
12357
|
-
*/
|
|
12358
|
-
_this.destroyed = false;
|
|
12359
12444
|
/**
|
|
12360
12445
|
* compatible with `style`
|
|
12361
12446
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style
|
|
@@ -12393,6 +12478,22 @@ var Element = /*#__PURE__*/function (_Node) {
|
|
|
12393
12478
|
}
|
|
12394
12479
|
_inherits(Element, _Node);
|
|
12395
12480
|
return _createClass(Element, [{
|
|
12481
|
+
key: "dirty",
|
|
12482
|
+
value:
|
|
12483
|
+
/**
|
|
12484
|
+
* @param flag - default `true`, whether the object needs to be updated
|
|
12485
|
+
* @param updateShape - default `false`, whether the bounding box of the object is updated
|
|
12486
|
+
*/
|
|
12487
|
+
function dirty() {
|
|
12488
|
+
var flag = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
12489
|
+
var updateShape = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
12490
|
+
this.renderable.dirty = flag;
|
|
12491
|
+
if (updateShape) {
|
|
12492
|
+
this.renderable.boundsDirty = flag;
|
|
12493
|
+
this.renderable.renderBoundsDirty = flag;
|
|
12494
|
+
}
|
|
12495
|
+
}
|
|
12496
|
+
}, {
|
|
12396
12497
|
key: "className",
|
|
12397
12498
|
get:
|
|
12398
12499
|
/**
|
|
@@ -12532,10 +12633,12 @@ var Element = /*#__PURE__*/function (_Node) {
|
|
|
12532
12633
|
}, {
|
|
12533
12634
|
key: "removeChild",
|
|
12534
12635
|
value: function removeChild(child) {
|
|
12535
|
-
var _child$ownerDocument;
|
|
12636
|
+
var _this$ownerDocument2, _child$ownerDocument;
|
|
12637
|
+
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;
|
|
12638
|
+
|
|
12536
12639
|
// should emit on itself before detach
|
|
12537
12640
|
removedEvent.relatedNode = this;
|
|
12538
|
-
child.dispatchEvent(removedEvent);
|
|
12641
|
+
child.dispatchEvent(removedEvent, enableCancelEventPropagation, enableCancelEventPropagation);
|
|
12539
12642
|
if ((_child$ownerDocument = child.ownerDocument) !== null && _child$ownerDocument !== void 0 && _child$ownerDocument.defaultView) {
|
|
12540
12643
|
child.ownerDocument.defaultView.unmountChildren(child);
|
|
12541
12644
|
}
|
|
@@ -12762,11 +12865,14 @@ var Element = /*#__PURE__*/function (_Node) {
|
|
|
12762
12865
|
}, {
|
|
12763
12866
|
key: "destroy",
|
|
12764
12867
|
value: function destroy() {
|
|
12868
|
+
var _this$ownerDocument3;
|
|
12869
|
+
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;
|
|
12870
|
+
|
|
12765
12871
|
// fix https://github.com/antvis/G/issues/1813
|
|
12766
12872
|
this.destroyChildren();
|
|
12767
12873
|
|
|
12768
12874
|
// destroy itself before remove
|
|
12769
|
-
this.dispatchEvent(destroyEvent);
|
|
12875
|
+
this.dispatchEvent(destroyEvent, enableCancelEventPropagation, enableCancelEventPropagation);
|
|
12770
12876
|
|
|
12771
12877
|
// remove from scenegraph first
|
|
12772
12878
|
this.remove();
|
|
@@ -13097,7 +13203,7 @@ var DisplayObject = /*#__PURE__*/function (_Element) {
|
|
|
13097
13203
|
runtime.styleValueRegistry.processProperties(this, attributes, options);
|
|
13098
13204
|
|
|
13099
13205
|
// redraw at next frame
|
|
13100
|
-
this.
|
|
13206
|
+
this.dirty();
|
|
13101
13207
|
}
|
|
13102
13208
|
}, {
|
|
13103
13209
|
key: "setAttribute",
|
|
@@ -13123,13 +13229,15 @@ var DisplayObject = /*#__PURE__*/function (_Element) {
|
|
|
13123
13229
|
key: "internalSetAttribute",
|
|
13124
13230
|
value: function internalSetAttribute(name, value) {
|
|
13125
13231
|
var parseOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
13126
|
-
var renderable = this.renderable;
|
|
13127
13232
|
var oldValue = this.attributes[name];
|
|
13128
13233
|
var oldParsedValue = this.parsedStyle[name];
|
|
13129
13234
|
runtime.styleValueRegistry.processProperties(this, _defineProperty({}, name, value), parseOptions);
|
|
13130
13235
|
|
|
13131
13236
|
// redraw at next frame
|
|
13132
|
-
|
|
13237
|
+
this.dirty();
|
|
13238
|
+
|
|
13239
|
+
// return;
|
|
13240
|
+
|
|
13133
13241
|
var newParsedValue = this.parsedStyle[name];
|
|
13134
13242
|
if (this.isConnected) {
|
|
13135
13243
|
attrModifiedEvent.relatedNode = this;
|
|
@@ -13141,8 +13249,10 @@ var DisplayObject = /*#__PURE__*/function (_Element) {
|
|
|
13141
13249
|
if (this.isMutationObserved) {
|
|
13142
13250
|
this.dispatchEvent(attrModifiedEvent);
|
|
13143
13251
|
} else {
|
|
13252
|
+
var _this$ownerDocument$d;
|
|
13253
|
+
var enableCancelEventPropagation = ((_this$ownerDocument$d = this.ownerDocument.defaultView.getConfig().future) === null || _this$ownerDocument$d === void 0 ? void 0 : _this$ownerDocument$d.experimentalCancelEventPropagation) === true;
|
|
13144
13254
|
attrModifiedEvent.target = this;
|
|
13145
|
-
this.ownerDocument.defaultView.dispatchEvent(attrModifiedEvent, true);
|
|
13255
|
+
this.ownerDocument.defaultView.dispatchEvent(attrModifiedEvent, true, enableCancelEventPropagation);
|
|
13146
13256
|
}
|
|
13147
13257
|
}
|
|
13148
13258
|
if (this.isCustomElement && this.isConnected || !this.isCustomElement) {
|
|
@@ -15035,7 +15145,7 @@ var Document = /*#__PURE__*/function (_Node) {
|
|
|
15035
15145
|
value: (function () {
|
|
15036
15146
|
var _elementFromPoint = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(x, y) {
|
|
15037
15147
|
var _this$defaultView$can2, viewportX, viewportY, _this$defaultView$get3, width, height, _this$defaultView$vie2, clientX, clientY, _yield$this$defaultVi, picked;
|
|
15038
|
-
return _regeneratorRuntime().wrap(function
|
|
15148
|
+
return _regeneratorRuntime().wrap(function (_context) {
|
|
15039
15149
|
while (1) switch (_context.prev = _context.next) {
|
|
15040
15150
|
case 0:
|
|
15041
15151
|
_this$defaultView$can2 = this.defaultView.canvas2Viewport({
|
|
@@ -15044,16 +15154,16 @@ var Document = /*#__PURE__*/function (_Node) {
|
|
|
15044
15154
|
}), viewportX = _this$defaultView$can2.x, viewportY = _this$defaultView$can2.y;
|
|
15045
15155
|
_this$defaultView$get3 = this.defaultView.getConfig(), width = _this$defaultView$get3.width, height = _this$defaultView$get3.height; // outside canvas' viewport
|
|
15046
15156
|
if (!(viewportX < 0 || viewportY < 0 || viewportX > width || viewportY > height)) {
|
|
15047
|
-
_context.next =
|
|
15157
|
+
_context.next = 1;
|
|
15048
15158
|
break;
|
|
15049
15159
|
}
|
|
15050
15160
|
return _context.abrupt("return", null);
|
|
15051
|
-
case
|
|
15161
|
+
case 1:
|
|
15052
15162
|
_this$defaultView$vie2 = this.defaultView.viewport2Client({
|
|
15053
15163
|
x: viewportX,
|
|
15054
15164
|
y: viewportY
|
|
15055
15165
|
}), clientX = _this$defaultView$vie2.x, clientY = _this$defaultView$vie2.y;
|
|
15056
|
-
_context.next =
|
|
15166
|
+
_context.next = 2;
|
|
15057
15167
|
return this.defaultView.getRenderingService().hooks.pick.promise({
|
|
15058
15168
|
topmost: true,
|
|
15059
15169
|
position: {
|
|
@@ -15066,11 +15176,11 @@ var Document = /*#__PURE__*/function (_Node) {
|
|
|
15066
15176
|
},
|
|
15067
15177
|
picked: []
|
|
15068
15178
|
});
|
|
15069
|
-
case
|
|
15179
|
+
case 2:
|
|
15070
15180
|
_yield$this$defaultVi = _context.sent;
|
|
15071
15181
|
picked = _yield$this$defaultVi.picked;
|
|
15072
15182
|
return _context.abrupt("return", picked && picked[0] || this.documentElement);
|
|
15073
|
-
case
|
|
15183
|
+
case 3:
|
|
15074
15184
|
case "end":
|
|
15075
15185
|
return _context.stop();
|
|
15076
15186
|
}
|
|
@@ -15132,7 +15242,7 @@ var Document = /*#__PURE__*/function (_Node) {
|
|
|
15132
15242
|
value: (function () {
|
|
15133
15243
|
var _elementsFromPoint = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(x, y) {
|
|
15134
15244
|
var _this$defaultView$can4, viewportX, viewportY, _this$defaultView$get6, width, height, _this$defaultView$vie4, clientX, clientY, _yield$this$defaultVi2, picked;
|
|
15135
|
-
return _regeneratorRuntime().wrap(function
|
|
15245
|
+
return _regeneratorRuntime().wrap(function (_context2) {
|
|
15136
15246
|
while (1) switch (_context2.prev = _context2.next) {
|
|
15137
15247
|
case 0:
|
|
15138
15248
|
_this$defaultView$can4 = this.defaultView.canvas2Viewport({
|
|
@@ -15141,16 +15251,16 @@ var Document = /*#__PURE__*/function (_Node) {
|
|
|
15141
15251
|
}), viewportX = _this$defaultView$can4.x, viewportY = _this$defaultView$can4.y;
|
|
15142
15252
|
_this$defaultView$get6 = this.defaultView.getConfig(), width = _this$defaultView$get6.width, height = _this$defaultView$get6.height; // outside canvas' viewport
|
|
15143
15253
|
if (!(viewportX < 0 || viewportY < 0 || viewportX > width || viewportY > height)) {
|
|
15144
|
-
_context2.next =
|
|
15254
|
+
_context2.next = 1;
|
|
15145
15255
|
break;
|
|
15146
15256
|
}
|
|
15147
15257
|
return _context2.abrupt("return", []);
|
|
15148
|
-
case
|
|
15258
|
+
case 1:
|
|
15149
15259
|
_this$defaultView$vie4 = this.defaultView.viewport2Client({
|
|
15150
15260
|
x: viewportX,
|
|
15151
15261
|
y: viewportY
|
|
15152
15262
|
}), clientX = _this$defaultView$vie4.x, clientY = _this$defaultView$vie4.y;
|
|
15153
|
-
_context2.next =
|
|
15263
|
+
_context2.next = 2;
|
|
15154
15264
|
return this.defaultView.getRenderingService().hooks.pick.promise({
|
|
15155
15265
|
topmost: false,
|
|
15156
15266
|
position: {
|
|
@@ -15163,14 +15273,14 @@ var Document = /*#__PURE__*/function (_Node) {
|
|
|
15163
15273
|
},
|
|
15164
15274
|
picked: []
|
|
15165
15275
|
});
|
|
15166
|
-
case
|
|
15276
|
+
case 2:
|
|
15167
15277
|
_yield$this$defaultVi2 = _context2.sent;
|
|
15168
15278
|
picked = _yield$this$defaultVi2.picked;
|
|
15169
15279
|
if (picked[picked.length - 1] !== this.documentElement) {
|
|
15170
15280
|
picked.push(this.documentElement);
|
|
15171
15281
|
}
|
|
15172
15282
|
return _context2.abrupt("return", picked);
|
|
15173
|
-
case
|
|
15283
|
+
case 3:
|
|
15174
15284
|
case "end":
|
|
15175
15285
|
return _context2.stop();
|
|
15176
15286
|
}
|
|
@@ -15275,12 +15385,14 @@ var CullingPlugin = /*#__PURE__*/function () {
|
|
|
15275
15385
|
return _createClass(CullingPlugin, [{
|
|
15276
15386
|
key: "apply",
|
|
15277
15387
|
value: function apply(context) {
|
|
15278
|
-
var
|
|
15388
|
+
var config = context.config,
|
|
15389
|
+
camera = context.camera,
|
|
15279
15390
|
renderingService = context.renderingService,
|
|
15280
15391
|
renderingContext = context.renderingContext;
|
|
15281
15392
|
var strategies = this.strategies;
|
|
15282
15393
|
renderingService.hooks.cull.tap(CullingPlugin.tag, function (object) {
|
|
15283
15394
|
if (object) {
|
|
15395
|
+
var _config$future;
|
|
15284
15396
|
var cullable = object.cullable;
|
|
15285
15397
|
// cullable.visible = true;
|
|
15286
15398
|
// const renderBounds = object.getRenderBounds();
|
|
@@ -15305,8 +15417,10 @@ var CullingPlugin = /*#__PURE__*/function () {
|
|
|
15305
15417
|
if (!object.isCulled() && object.isVisible()) {
|
|
15306
15418
|
return object;
|
|
15307
15419
|
}
|
|
15420
|
+
var enableCancelEventPropagation = ((_config$future = config.future) === null || _config$future === void 0 ? void 0 : _config$future.experimentalCancelEventPropagation) === true;
|
|
15421
|
+
|
|
15308
15422
|
// if (this.renderingContext.renderListLastFrame.indexOf(object) > -1) {
|
|
15309
|
-
object.dispatchEvent(new CustomEvent(ElementEvent.CULLED));
|
|
15423
|
+
object.dispatchEvent(new CustomEvent(ElementEvent.CULLED), enableCancelEventPropagation, enableCancelEventPropagation);
|
|
15310
15424
|
// }
|
|
15311
15425
|
|
|
15312
15426
|
return null;
|
|
@@ -15721,15 +15835,15 @@ var PrepareRendererPlugin = /*#__PURE__*/function () {
|
|
|
15721
15835
|
key: "apply",
|
|
15722
15836
|
value: function apply(context) {
|
|
15723
15837
|
var _this = this,
|
|
15724
|
-
_runtime$globalThis$r
|
|
15725
|
-
|
|
15838
|
+
_runtime$globalThis$r,
|
|
15839
|
+
_config$future;
|
|
15840
|
+
var config = context.config,
|
|
15841
|
+
renderingService = context.renderingService,
|
|
15726
15842
|
renderingContext = context.renderingContext,
|
|
15727
15843
|
rBushRoot = context.rBushRoot;
|
|
15728
15844
|
var canvas = renderingContext.root.ownerDocument.defaultView;
|
|
15729
15845
|
this.rBush = rBushRoot;
|
|
15730
15846
|
var handleAttributeChanged = function handleAttributeChanged(e) {
|
|
15731
|
-
var object = e.target;
|
|
15732
|
-
object.renderable.dirty = true;
|
|
15733
15847
|
renderingService.dirtify();
|
|
15734
15848
|
};
|
|
15735
15849
|
var handleBoundsChanged = function handleBoundsChanged(e) {
|
|
@@ -15745,11 +15859,11 @@ var PrepareRendererPlugin = /*#__PURE__*/function () {
|
|
|
15745
15859
|
var handleUnmounted = function handleUnmounted(e) {
|
|
15746
15860
|
var object = e.target;
|
|
15747
15861
|
var rBushNode = object.rBushNode;
|
|
15748
|
-
if (rBushNode.aabb) {
|
|
15862
|
+
if (rBushNode !== null && rBushNode !== void 0 && rBushNode.aabb) {
|
|
15749
15863
|
_this.rBush.remove(rBushNode.aabb);
|
|
15750
15864
|
}
|
|
15751
15865
|
_this.syncTasks["delete"](object);
|
|
15752
|
-
runtime.sceneGraphService.
|
|
15866
|
+
runtime.sceneGraphService.dirtyToRoot(object);
|
|
15753
15867
|
renderingService.dirtify();
|
|
15754
15868
|
};
|
|
15755
15869
|
renderingService.hooks.init.tap(PrepareRendererPlugin.tag, function () {
|
|
@@ -15766,6 +15880,7 @@ var PrepareRendererPlugin = /*#__PURE__*/function () {
|
|
|
15766
15880
|
_this.syncTasks.clear();
|
|
15767
15881
|
});
|
|
15768
15882
|
var ric = (_runtime$globalThis$r = runtime.globalThis.requestIdleCallback) !== null && _runtime$globalThis$r !== void 0 ? _runtime$globalThis$r : raf.bind(runtime.globalThis);
|
|
15883
|
+
var enableRICSyncRTree = ((_config$future = config.future) === null || _config$future === void 0 ? void 0 : _config$future.experimentalRICSyncRTree) === true;
|
|
15769
15884
|
renderingService.hooks.endFrame.tap(PrepareRendererPlugin.tag, function () {
|
|
15770
15885
|
if (_this.isFirstTimeRendering) {
|
|
15771
15886
|
_this.isFirstTimeRendering = false;
|
|
@@ -15774,6 +15889,11 @@ var PrepareRendererPlugin = /*#__PURE__*/function () {
|
|
|
15774
15889
|
_this.syncRTree(true);
|
|
15775
15890
|
_this.isFirstTimeRenderingFinished = true;
|
|
15776
15891
|
});
|
|
15892
|
+
} else if (enableRICSyncRTree && runtime.globalThis.requestIdleCallback && runtime.globalThis.cancelIdleCallback) {
|
|
15893
|
+
runtime.globalThis.cancelIdleCallback(_this.ricSyncRTreeId);
|
|
15894
|
+
_this.ricSyncRTreeId = runtime.globalThis.requestIdleCallback(function () {
|
|
15895
|
+
return _this.syncRTree();
|
|
15896
|
+
});
|
|
15777
15897
|
} else {
|
|
15778
15898
|
_this.syncRTree();
|
|
15779
15899
|
}
|
|
@@ -15957,6 +16077,9 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
15957
16077
|
_this.devicePixelRatio = dpr;
|
|
15958
16078
|
_this.requestAnimationFrame = requestAnimationFrame !== null && requestAnimationFrame !== void 0 ? requestAnimationFrame : raf.bind(runtime.globalThis);
|
|
15959
16079
|
_this.cancelAnimationFrame = cancelAnimationFrame !== null && cancelAnimationFrame !== void 0 ? cancelAnimationFrame : caf.bind(runtime.globalThis);
|
|
16080
|
+
_this.createImage = createImage !== null && createImage !== void 0 ? createImage : function () {
|
|
16081
|
+
return new window.Image();
|
|
16082
|
+
};
|
|
15960
16083
|
// the following feature-detect from hammer.js
|
|
15961
16084
|
// @see https://github.com/hammerjs/hammer.js/blob/master/src/inputjs/input-consts.js#L5
|
|
15962
16085
|
_this.supportsTouchEvents = supportsTouchEvents !== null && supportsTouchEvents !== void 0 ? supportsTouchEvents : 'ontouchstart' in runtime.globalThis;
|
|
@@ -15988,14 +16111,12 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
15988
16111
|
devicePixelRatio: dpr,
|
|
15989
16112
|
requestAnimationFrame: _this.requestAnimationFrame,
|
|
15990
16113
|
cancelAnimationFrame: _this.cancelAnimationFrame,
|
|
16114
|
+
createImage: _this.createImage,
|
|
15991
16115
|
supportsTouchEvents: _this.supportsTouchEvents,
|
|
15992
16116
|
supportsPointerEvents: _this.supportsPointerEvents,
|
|
15993
16117
|
isTouchEvent: _this.isTouchEvent,
|
|
15994
16118
|
isMouseEvent: _this.isMouseEvent,
|
|
15995
|
-
dblClickSpeed: dblClickSpeed !== null && dblClickSpeed !== void 0 ? dblClickSpeed : 200
|
|
15996
|
-
createImage: createImage !== null && createImage !== void 0 ? createImage : function () {
|
|
15997
|
-
return new window.Image();
|
|
15998
|
-
}
|
|
16119
|
+
dblClickSpeed: dblClickSpeed !== null && dblClickSpeed !== void 0 ? dblClickSpeed : 200
|
|
15999
16120
|
}));
|
|
16000
16121
|
_this.initDefaultCamera(canvasWidth, canvasHeight, renderer.clipSpaceNearZ);
|
|
16001
16122
|
_this.initRenderer(renderer, true);
|
|
@@ -16013,8 +16134,8 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
16013
16134
|
* the root node in scene graph
|
|
16014
16135
|
*/
|
|
16015
16136
|
root: this.document.documentElement,
|
|
16016
|
-
renderListCurrentFrame: [],
|
|
16017
16137
|
unculledEntities: [],
|
|
16138
|
+
renderListCurrentFrame: [],
|
|
16018
16139
|
renderReasons: new Set(),
|
|
16019
16140
|
force: false,
|
|
16020
16141
|
dirty: false
|
|
@@ -16131,11 +16252,13 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
16131
16252
|
}, {
|
|
16132
16253
|
key: "destroy",
|
|
16133
16254
|
value: function destroy() {
|
|
16255
|
+
var _this$getConfig$futur;
|
|
16134
16256
|
var cleanUp = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
16135
16257
|
var skipTriggerEvent = arguments.length > 1 ? arguments[1] : undefined;
|
|
16136
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;
|
|
16137
16260
|
if (!skipTriggerEvent) {
|
|
16138
|
-
this.dispatchEvent(new CustomEvent(CanvasEvent.BEFORE_DESTROY));
|
|
16261
|
+
this.dispatchEvent(new CustomEvent(CanvasEvent.BEFORE_DESTROY), enableCancelEventPropagation, enableCancelEventPropagation);
|
|
16139
16262
|
}
|
|
16140
16263
|
if (this.frameId) {
|
|
16141
16264
|
this.cancelAnimationFrame(this.frameId);
|
|
@@ -16160,7 +16283,7 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
16160
16283
|
this.context.rBushRoot.clear();
|
|
16161
16284
|
}
|
|
16162
16285
|
if (!skipTriggerEvent) {
|
|
16163
|
-
this.dispatchEvent(new CustomEvent(CanvasEvent.AFTER_DESTROY));
|
|
16286
|
+
this.dispatchEvent(new CustomEvent(CanvasEvent.AFTER_DESTROY), enableCancelEventPropagation, enableCancelEventPropagation);
|
|
16164
16287
|
}
|
|
16165
16288
|
var clearEventRetain = function clearEventRetain(event) {
|
|
16166
16289
|
event.currentTarget = null;
|
|
@@ -16192,6 +16315,7 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
16192
16315
|
}, {
|
|
16193
16316
|
key: "resize",
|
|
16194
16317
|
value: function resize(width, height) {
|
|
16318
|
+
var _canvasConfig$future;
|
|
16195
16319
|
// update canvas' config
|
|
16196
16320
|
var canvasConfig = this.context.config;
|
|
16197
16321
|
canvasConfig.width = width;
|
|
@@ -16209,10 +16333,11 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
16209
16333
|
} else {
|
|
16210
16334
|
camera.setAspect(width / height);
|
|
16211
16335
|
}
|
|
16336
|
+
var enableCancelEventPropagation = ((_canvasConfig$future = canvasConfig.future) === null || _canvasConfig$future === void 0 ? void 0 : _canvasConfig$future.experimentalCancelEventPropagation) === true;
|
|
16212
16337
|
this.dispatchEvent(new CustomEvent(CanvasEvent.RESIZE, {
|
|
16213
16338
|
width: width,
|
|
16214
16339
|
height: height
|
|
16215
|
-
}));
|
|
16340
|
+
}), enableCancelEventPropagation, enableCancelEventPropagation);
|
|
16216
16341
|
}
|
|
16217
16342
|
|
|
16218
16343
|
// proxy to document.documentElement
|
|
@@ -16253,20 +16378,22 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
16253
16378
|
}, {
|
|
16254
16379
|
key: "render",
|
|
16255
16380
|
value: function render(frame) {
|
|
16256
|
-
var
|
|
16381
|
+
var _this$getConfig$futur2,
|
|
16382
|
+
_this4 = this;
|
|
16257
16383
|
// console.log('render ----------------------');
|
|
16258
16384
|
if (frame) {
|
|
16259
16385
|
beforeRenderEvent.detail = frame;
|
|
16260
16386
|
afterRenderEvent.detail = frame;
|
|
16261
16387
|
}
|
|
16262
|
-
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);
|
|
16263
16390
|
var renderingService = this.getRenderingService();
|
|
16264
16391
|
renderingService.render(this.getConfig(), frame, function () {
|
|
16265
16392
|
// trigger actual rerender event
|
|
16266
16393
|
// @see https://github.com/antvis/G/issues/1268
|
|
16267
|
-
_this4.dispatchEvent(rerenderEvent);
|
|
16394
|
+
_this4.dispatchEvent(rerenderEvent, enableCancelEventPropagation, enableCancelEventPropagation);
|
|
16268
16395
|
});
|
|
16269
|
-
this.dispatchEvent(afterRenderEvent);
|
|
16396
|
+
this.dispatchEvent(afterRenderEvent, enableCancelEventPropagation, enableCancelEventPropagation);
|
|
16270
16397
|
}
|
|
16271
16398
|
}, {
|
|
16272
16399
|
key: "run",
|
|
@@ -16330,30 +16457,27 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
16330
16457
|
var firstContentfullPaint = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
16331
16458
|
var async = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
16332
16459
|
this.context.renderingService.init(function () {
|
|
16460
|
+
var _this7$getConfig$futu;
|
|
16333
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;
|
|
16334
16463
|
if (firstContentfullPaint) {
|
|
16335
16464
|
if (async) {
|
|
16336
16465
|
_this7.requestAnimationFrame(function () {
|
|
16337
|
-
_this7.dispatchEvent(new CustomEvent(CanvasEvent.READY));
|
|
16466
|
+
_this7.dispatchEvent(new CustomEvent(CanvasEvent.READY), enableCancelEventPropagation, enableCancelEventPropagation);
|
|
16338
16467
|
});
|
|
16339
16468
|
} else {
|
|
16340
|
-
_this7.dispatchEvent(new CustomEvent(CanvasEvent.READY));
|
|
16469
|
+
_this7.dispatchEvent(new CustomEvent(CanvasEvent.READY), enableCancelEventPropagation, enableCancelEventPropagation);
|
|
16341
16470
|
}
|
|
16342
16471
|
} else {
|
|
16343
|
-
_this7.dispatchEvent(new CustomEvent(CanvasEvent.RENDERER_CHANGED));
|
|
16472
|
+
_this7.dispatchEvent(new CustomEvent(CanvasEvent.RENDERER_CHANGED), enableCancelEventPropagation, enableCancelEventPropagation);
|
|
16344
16473
|
}
|
|
16345
16474
|
if (_this7.readyPromise) {
|
|
16346
16475
|
_this7.resolveReadyPromise();
|
|
16347
16476
|
}
|
|
16348
16477
|
if (!firstContentfullPaint) {
|
|
16349
16478
|
_this7.getRoot().forEach(function (node) {
|
|
16350
|
-
var _ref
|
|
16351
|
-
|
|
16352
|
-
if (renderable) {
|
|
16353
|
-
renderable.renderBoundsDirty = true;
|
|
16354
|
-
renderable.boundsDirty = true;
|
|
16355
|
-
renderable.dirty = true;
|
|
16356
|
-
}
|
|
16479
|
+
var _dirty, _ref;
|
|
16480
|
+
(_dirty = (_ref = node).dirty) === null || _dirty === void 0 || _dirty.call(_ref, true, true);
|
|
16357
16481
|
});
|
|
16358
16482
|
}
|
|
16359
16483
|
|
|
@@ -16414,8 +16538,10 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
16414
16538
|
if (parent.isMutationObserved) {
|
|
16415
16539
|
parent.dispatchEvent(unmountedEvent);
|
|
16416
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;
|
|
16417
16543
|
unmountedEvent.target = parent;
|
|
16418
|
-
this.dispatchEvent(unmountedEvent, true);
|
|
16544
|
+
this.dispatchEvent(unmountedEvent, true, enableCancelEventPropagation);
|
|
16419
16545
|
}
|
|
16420
16546
|
|
|
16421
16547
|
// skip document.documentElement
|
|
@@ -16445,8 +16571,10 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
16445
16571
|
if (child.isMutationObserved) {
|
|
16446
16572
|
child.dispatchEvent(mountedEvent);
|
|
16447
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;
|
|
16448
16576
|
mountedEvent.target = child;
|
|
16449
|
-
this.dispatchEvent(mountedEvent, true);
|
|
16577
|
+
this.dispatchEvent(mountedEvent, true, enableCancelEventPropagation);
|
|
16450
16578
|
}
|
|
16451
16579
|
}
|
|
16452
16580
|
}
|
|
@@ -16632,4 +16760,6 @@ exports.runtime = runtime;
|
|
|
16632
16760
|
exports.setDOMSize = setDOMSize;
|
|
16633
16761
|
exports.translatePathToString = translatePathToString;
|
|
16634
16762
|
exports.turn2deg = turn2deg;
|
|
16763
|
+
exports.updateLocalTransform = updateLocalTransform;
|
|
16764
|
+
exports.updateWorldTransform = updateWorldTransform;
|
|
16635
16765
|
//# sourceMappingURL=index.js.map
|