@antv/g-lite 2.3.2 → 2.4.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/dist/index.esm.js +179 -837
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +178 -837
- package/dist/index.js.map +1 -1
- package/dist/index.umd.min.js +11 -11
- package/dist/index.umd.min.js.map +1 -1
- package/package.json +1 -3
- package/types/Canvas.d.ts.map +1 -1
- package/types/components/RBushNode.d.ts +10 -0
- package/types/components/RBushNode.d.ts.map +1 -1
- package/types/css/StyleValueRegistry.d.ts.map +1 -1
- package/types/display-objects/DisplayObject.d.ts +1 -2
- package/types/display-objects/DisplayObject.d.ts.map +1 -1
- package/types/display-objects/Text.d.ts +5 -0
- package/types/display-objects/Text.d.ts.map +1 -1
- package/types/dom/CustomEvent.d.ts +7 -3
- package/types/dom/CustomEvent.d.ts.map +1 -1
- package/types/dom/Document.d.ts +2 -3
- package/types/dom/Document.d.ts.map +1 -1
- package/types/dom/Element.d.ts +22 -8
- package/types/dom/Element.d.ts.map +1 -1
- package/types/dom/EventTarget.d.ts +2 -2
- package/types/dom/EventTarget.d.ts.map +1 -1
- package/types/dom/MutationEvent.d.ts +3 -0
- package/types/dom/MutationEvent.d.ts.map +1 -1
- package/types/dom/MutationObserver.d.ts +19 -0
- package/types/dom/MutationObserver.d.ts.map +1 -0
- package/types/dom/index.d.ts +1 -0
- package/types/dom/index.d.ts.map +1 -1
- package/types/dom/interfaces.d.ts +0 -3
- package/types/dom/interfaces.d.ts.map +1 -1
- package/types/index.d.ts +0 -2
- package/types/index.d.ts.map +1 -1
- package/types/plugins/PrepareRendererPlugin.d.ts +5 -6
- package/types/plugins/PrepareRendererPlugin.d.ts.map +1 -1
- package/types/services/RenderingService.d.ts +4 -3
- package/types/services/RenderingService.d.ts.map +1 -1
- package/types/services/SceneGraphService.d.ts +19 -9
- package/types/services/SceneGraphService.d.ts.map +1 -1
- package/types/services/interfaces.d.ts +4 -3
- package/types/services/interfaces.d.ts.map +1 -1
- 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.4.1
|
|
5
|
+
* @date 10/13/2025, 12:16:48 PM
|
|
6
6
|
* @author AntVis
|
|
7
7
|
* @docs https://g.antv.antgroup.com/
|
|
8
8
|
*/
|
|
@@ -27,585 +27,7 @@ var _asyncToGenerator = require('@babel/runtime/helpers/asyncToGenerator');
|
|
|
27
27
|
var _createForOfIteratorHelper = require('@babel/runtime/helpers/createForOfIteratorHelper');
|
|
28
28
|
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
var rbush = {exports: {}};
|
|
33
|
-
|
|
34
|
-
(function (module, exports) {
|
|
35
|
-
(function (global, factory) {
|
|
36
|
-
module.exports = factory() ;
|
|
37
|
-
}(commonjsGlobal, function () {
|
|
38
|
-
function quickselect(arr, k, left, right, compare) {
|
|
39
|
-
quickselectStep(arr, k, left || 0, right || (arr.length - 1), compare || defaultCompare);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function quickselectStep(arr, k, left, right, compare) {
|
|
43
|
-
|
|
44
|
-
while (right > left) {
|
|
45
|
-
if (right - left > 600) {
|
|
46
|
-
var n = right - left + 1;
|
|
47
|
-
var m = k - left + 1;
|
|
48
|
-
var z = Math.log(n);
|
|
49
|
-
var s = 0.5 * Math.exp(2 * z / 3);
|
|
50
|
-
var sd = 0.5 * Math.sqrt(z * s * (n - s) / n) * (m - n / 2 < 0 ? -1 : 1);
|
|
51
|
-
var newLeft = Math.max(left, Math.floor(k - m * s / n + sd));
|
|
52
|
-
var newRight = Math.min(right, Math.floor(k + (n - m) * s / n + sd));
|
|
53
|
-
quickselectStep(arr, k, newLeft, newRight, compare);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
var t = arr[k];
|
|
57
|
-
var i = left;
|
|
58
|
-
var j = right;
|
|
59
|
-
|
|
60
|
-
swap(arr, left, k);
|
|
61
|
-
if (compare(arr[right], t) > 0) { swap(arr, left, right); }
|
|
62
|
-
|
|
63
|
-
while (i < j) {
|
|
64
|
-
swap(arr, i, j);
|
|
65
|
-
i++;
|
|
66
|
-
j--;
|
|
67
|
-
while (compare(arr[i], t) < 0) { i++; }
|
|
68
|
-
while (compare(arr[j], t) > 0) { j--; }
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (compare(arr[left], t) === 0) { swap(arr, left, j); }
|
|
72
|
-
else {
|
|
73
|
-
j++;
|
|
74
|
-
swap(arr, j, right);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (j <= k) { left = j + 1; }
|
|
78
|
-
if (k <= j) { right = j - 1; }
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function swap(arr, i, j) {
|
|
83
|
-
var tmp = arr[i];
|
|
84
|
-
arr[i] = arr[j];
|
|
85
|
-
arr[j] = tmp;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function defaultCompare(a, b) {
|
|
89
|
-
return a < b ? -1 : a > b ? 1 : 0;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
var RBush = function RBush(maxEntries) {
|
|
93
|
-
if ( maxEntries === void 0 ) maxEntries = 9;
|
|
94
|
-
|
|
95
|
-
// max entries in a node is 9 by default; min node fill is 40% for best performance
|
|
96
|
-
this._maxEntries = Math.max(4, maxEntries);
|
|
97
|
-
this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4));
|
|
98
|
-
this.clear();
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
RBush.prototype.all = function all () {
|
|
102
|
-
return this._all(this.data, []);
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
RBush.prototype.search = function search (bbox) {
|
|
106
|
-
var node = this.data;
|
|
107
|
-
var result = [];
|
|
108
|
-
|
|
109
|
-
if (!intersects(bbox, node)) { return result; }
|
|
110
|
-
|
|
111
|
-
var toBBox = this.toBBox;
|
|
112
|
-
var nodesToSearch = [];
|
|
113
|
-
|
|
114
|
-
while (node) {
|
|
115
|
-
for (var i = 0; i < node.children.length; i++) {
|
|
116
|
-
var child = node.children[i];
|
|
117
|
-
var childBBox = node.leaf ? toBBox(child) : child;
|
|
118
|
-
|
|
119
|
-
if (intersects(bbox, childBBox)) {
|
|
120
|
-
if (node.leaf) { result.push(child); }
|
|
121
|
-
else if (contains(bbox, childBBox)) { this._all(child, result); }
|
|
122
|
-
else { nodesToSearch.push(child); }
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
node = nodesToSearch.pop();
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
return result;
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
RBush.prototype.collides = function collides (bbox) {
|
|
132
|
-
var node = this.data;
|
|
133
|
-
|
|
134
|
-
if (!intersects(bbox, node)) { return false; }
|
|
135
|
-
|
|
136
|
-
var nodesToSearch = [];
|
|
137
|
-
while (node) {
|
|
138
|
-
for (var i = 0; i < node.children.length; i++) {
|
|
139
|
-
var child = node.children[i];
|
|
140
|
-
var childBBox = node.leaf ? this.toBBox(child) : child;
|
|
141
|
-
|
|
142
|
-
if (intersects(bbox, childBBox)) {
|
|
143
|
-
if (node.leaf || contains(bbox, childBBox)) { return true; }
|
|
144
|
-
nodesToSearch.push(child);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
node = nodesToSearch.pop();
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
return false;
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
RBush.prototype.load = function load (data) {
|
|
154
|
-
if (!(data && data.length)) { return this; }
|
|
155
|
-
|
|
156
|
-
if (data.length < this._minEntries) {
|
|
157
|
-
for (var i = 0; i < data.length; i++) {
|
|
158
|
-
this.insert(data[i]);
|
|
159
|
-
}
|
|
160
|
-
return this;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
// recursively build the tree with the given data from scratch using OMT algorithm
|
|
164
|
-
var node = this._build(data.slice(), 0, data.length - 1, 0);
|
|
165
|
-
|
|
166
|
-
if (!this.data.children.length) {
|
|
167
|
-
// save as is if tree is empty
|
|
168
|
-
this.data = node;
|
|
169
|
-
|
|
170
|
-
} else if (this.data.height === node.height) {
|
|
171
|
-
// split root if trees have the same height
|
|
172
|
-
this._splitRoot(this.data, node);
|
|
173
|
-
|
|
174
|
-
} else {
|
|
175
|
-
if (this.data.height < node.height) {
|
|
176
|
-
// swap trees if inserted one is bigger
|
|
177
|
-
var tmpNode = this.data;
|
|
178
|
-
this.data = node;
|
|
179
|
-
node = tmpNode;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
// insert the small tree into the large tree at appropriate level
|
|
183
|
-
this._insert(node, this.data.height - node.height - 1, true);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
return this;
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
RBush.prototype.insert = function insert (item) {
|
|
190
|
-
if (item) { this._insert(item, this.data.height - 1); }
|
|
191
|
-
return this;
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
RBush.prototype.clear = function clear () {
|
|
195
|
-
this.data = createNode([]);
|
|
196
|
-
return this;
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
RBush.prototype.remove = function remove (item, equalsFn) {
|
|
200
|
-
if (!item) { return this; }
|
|
201
|
-
|
|
202
|
-
var node = this.data;
|
|
203
|
-
var bbox = this.toBBox(item);
|
|
204
|
-
var path = [];
|
|
205
|
-
var indexes = [];
|
|
206
|
-
var i, parent, goingUp;
|
|
207
|
-
|
|
208
|
-
// depth-first iterative tree traversal
|
|
209
|
-
while (node || path.length) {
|
|
210
|
-
|
|
211
|
-
if (!node) { // go up
|
|
212
|
-
node = path.pop();
|
|
213
|
-
parent = path[path.length - 1];
|
|
214
|
-
i = indexes.pop();
|
|
215
|
-
goingUp = true;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
if (node.leaf) { // check current node
|
|
219
|
-
var index = findItem(item, node.children, equalsFn);
|
|
220
|
-
|
|
221
|
-
if (index !== -1) {
|
|
222
|
-
// item found, remove the item and condense tree upwards
|
|
223
|
-
node.children.splice(index, 1);
|
|
224
|
-
path.push(node);
|
|
225
|
-
this._condense(path);
|
|
226
|
-
return this;
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
if (!goingUp && !node.leaf && contains(node, bbox)) { // go down
|
|
231
|
-
path.push(node);
|
|
232
|
-
indexes.push(i);
|
|
233
|
-
i = 0;
|
|
234
|
-
parent = node;
|
|
235
|
-
node = node.children[0];
|
|
236
|
-
|
|
237
|
-
} else if (parent) { // go right
|
|
238
|
-
i++;
|
|
239
|
-
node = parent.children[i];
|
|
240
|
-
goingUp = false;
|
|
241
|
-
|
|
242
|
-
} else { node = null; } // nothing found
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
return this;
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
RBush.prototype.toBBox = function toBBox (item) { return item; };
|
|
249
|
-
|
|
250
|
-
RBush.prototype.compareMinX = function compareMinX (a, b) { return a.minX - b.minX; };
|
|
251
|
-
RBush.prototype.compareMinY = function compareMinY (a, b) { return a.minY - b.minY; };
|
|
252
|
-
|
|
253
|
-
RBush.prototype.toJSON = function toJSON () { return this.data; };
|
|
254
|
-
|
|
255
|
-
RBush.prototype.fromJSON = function fromJSON (data) {
|
|
256
|
-
this.data = data;
|
|
257
|
-
return this;
|
|
258
|
-
};
|
|
259
|
-
|
|
260
|
-
RBush.prototype._all = function _all (node, result) {
|
|
261
|
-
var nodesToSearch = [];
|
|
262
|
-
while (node) {
|
|
263
|
-
if (node.leaf) { result.push.apply(result, node.children); }
|
|
264
|
-
else { nodesToSearch.push.apply(nodesToSearch, node.children); }
|
|
265
|
-
|
|
266
|
-
node = nodesToSearch.pop();
|
|
267
|
-
}
|
|
268
|
-
return result;
|
|
269
|
-
};
|
|
270
|
-
|
|
271
|
-
RBush.prototype._build = function _build (items, left, right, height) {
|
|
272
|
-
|
|
273
|
-
var N = right - left + 1;
|
|
274
|
-
var M = this._maxEntries;
|
|
275
|
-
var node;
|
|
276
|
-
|
|
277
|
-
if (N <= M) {
|
|
278
|
-
// reached leaf level; return leaf
|
|
279
|
-
node = createNode(items.slice(left, right + 1));
|
|
280
|
-
calcBBox(node, this.toBBox);
|
|
281
|
-
return node;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
if (!height) {
|
|
285
|
-
// target height of the bulk-loaded tree
|
|
286
|
-
height = Math.ceil(Math.log(N) / Math.log(M));
|
|
287
|
-
|
|
288
|
-
// target number of root entries to maximize storage utilization
|
|
289
|
-
M = Math.ceil(N / Math.pow(M, height - 1));
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
node = createNode([]);
|
|
293
|
-
node.leaf = false;
|
|
294
|
-
node.height = height;
|
|
295
|
-
|
|
296
|
-
// split the items into M mostly square tiles
|
|
297
|
-
|
|
298
|
-
var N2 = Math.ceil(N / M);
|
|
299
|
-
var N1 = N2 * Math.ceil(Math.sqrt(M));
|
|
300
|
-
|
|
301
|
-
multiSelect(items, left, right, N1, this.compareMinX);
|
|
302
|
-
|
|
303
|
-
for (var i = left; i <= right; i += N1) {
|
|
304
|
-
|
|
305
|
-
var right2 = Math.min(i + N1 - 1, right);
|
|
306
|
-
|
|
307
|
-
multiSelect(items, i, right2, N2, this.compareMinY);
|
|
308
|
-
|
|
309
|
-
for (var j = i; j <= right2; j += N2) {
|
|
310
|
-
|
|
311
|
-
var right3 = Math.min(j + N2 - 1, right2);
|
|
312
|
-
|
|
313
|
-
// pack each entry recursively
|
|
314
|
-
node.children.push(this._build(items, j, right3, height - 1));
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
calcBBox(node, this.toBBox);
|
|
319
|
-
|
|
320
|
-
return node;
|
|
321
|
-
};
|
|
322
|
-
|
|
323
|
-
RBush.prototype._chooseSubtree = function _chooseSubtree (bbox, node, level, path) {
|
|
324
|
-
while (true) {
|
|
325
|
-
path.push(node);
|
|
326
|
-
|
|
327
|
-
if (node.leaf || path.length - 1 === level) { break; }
|
|
328
|
-
|
|
329
|
-
var minArea = Infinity;
|
|
330
|
-
var minEnlargement = Infinity;
|
|
331
|
-
var targetNode = (void 0);
|
|
332
|
-
|
|
333
|
-
for (var i = 0; i < node.children.length; i++) {
|
|
334
|
-
var child = node.children[i];
|
|
335
|
-
var area = bboxArea(child);
|
|
336
|
-
var enlargement = enlargedArea(bbox, child) - area;
|
|
337
|
-
|
|
338
|
-
// choose entry with the least area enlargement
|
|
339
|
-
if (enlargement < minEnlargement) {
|
|
340
|
-
minEnlargement = enlargement;
|
|
341
|
-
minArea = area < minArea ? area : minArea;
|
|
342
|
-
targetNode = child;
|
|
343
|
-
|
|
344
|
-
} else if (enlargement === minEnlargement) {
|
|
345
|
-
// otherwise choose one with the smallest area
|
|
346
|
-
if (area < minArea) {
|
|
347
|
-
minArea = area;
|
|
348
|
-
targetNode = child;
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
node = targetNode || node.children[0];
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
return node;
|
|
357
|
-
};
|
|
358
|
-
|
|
359
|
-
RBush.prototype._insert = function _insert (item, level, isNode) {
|
|
360
|
-
var bbox = isNode ? item : this.toBBox(item);
|
|
361
|
-
var insertPath = [];
|
|
362
|
-
|
|
363
|
-
// find the best node for accommodating the item, saving all nodes along the path too
|
|
364
|
-
var node = this._chooseSubtree(bbox, this.data, level, insertPath);
|
|
365
|
-
|
|
366
|
-
// put the item into the node
|
|
367
|
-
node.children.push(item);
|
|
368
|
-
extend(node, bbox);
|
|
369
|
-
|
|
370
|
-
// split on node overflow; propagate upwards if necessary
|
|
371
|
-
while (level >= 0) {
|
|
372
|
-
if (insertPath[level].children.length > this._maxEntries) {
|
|
373
|
-
this._split(insertPath, level);
|
|
374
|
-
level--;
|
|
375
|
-
} else { break; }
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
// adjust bboxes along the insertion path
|
|
379
|
-
this._adjustParentBBoxes(bbox, insertPath, level);
|
|
380
|
-
};
|
|
381
|
-
|
|
382
|
-
// split overflowed node into two
|
|
383
|
-
RBush.prototype._split = function _split (insertPath, level) {
|
|
384
|
-
var node = insertPath[level];
|
|
385
|
-
var M = node.children.length;
|
|
386
|
-
var m = this._minEntries;
|
|
387
|
-
|
|
388
|
-
this._chooseSplitAxis(node, m, M);
|
|
389
|
-
|
|
390
|
-
var splitIndex = this._chooseSplitIndex(node, m, M);
|
|
391
|
-
|
|
392
|
-
var newNode = createNode(node.children.splice(splitIndex, node.children.length - splitIndex));
|
|
393
|
-
newNode.height = node.height;
|
|
394
|
-
newNode.leaf = node.leaf;
|
|
395
|
-
|
|
396
|
-
calcBBox(node, this.toBBox);
|
|
397
|
-
calcBBox(newNode, this.toBBox);
|
|
398
|
-
|
|
399
|
-
if (level) { insertPath[level - 1].children.push(newNode); }
|
|
400
|
-
else { this._splitRoot(node, newNode); }
|
|
401
|
-
};
|
|
402
|
-
|
|
403
|
-
RBush.prototype._splitRoot = function _splitRoot (node, newNode) {
|
|
404
|
-
// split root node
|
|
405
|
-
this.data = createNode([node, newNode]);
|
|
406
|
-
this.data.height = node.height + 1;
|
|
407
|
-
this.data.leaf = false;
|
|
408
|
-
calcBBox(this.data, this.toBBox);
|
|
409
|
-
};
|
|
410
|
-
|
|
411
|
-
RBush.prototype._chooseSplitIndex = function _chooseSplitIndex (node, m, M) {
|
|
412
|
-
var index;
|
|
413
|
-
var minOverlap = Infinity;
|
|
414
|
-
var minArea = Infinity;
|
|
415
|
-
|
|
416
|
-
for (var i = m; i <= M - m; i++) {
|
|
417
|
-
var bbox1 = distBBox(node, 0, i, this.toBBox);
|
|
418
|
-
var bbox2 = distBBox(node, i, M, this.toBBox);
|
|
419
|
-
|
|
420
|
-
var overlap = intersectionArea(bbox1, bbox2);
|
|
421
|
-
var area = bboxArea(bbox1) + bboxArea(bbox2);
|
|
422
|
-
|
|
423
|
-
// choose distribution with minimum overlap
|
|
424
|
-
if (overlap < minOverlap) {
|
|
425
|
-
minOverlap = overlap;
|
|
426
|
-
index = i;
|
|
427
|
-
|
|
428
|
-
minArea = area < minArea ? area : minArea;
|
|
429
|
-
|
|
430
|
-
} else if (overlap === minOverlap) {
|
|
431
|
-
// otherwise choose distribution with minimum area
|
|
432
|
-
if (area < minArea) {
|
|
433
|
-
minArea = area;
|
|
434
|
-
index = i;
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
return index || M - m;
|
|
440
|
-
};
|
|
441
|
-
|
|
442
|
-
// sorts node children by the best axis for split
|
|
443
|
-
RBush.prototype._chooseSplitAxis = function _chooseSplitAxis (node, m, M) {
|
|
444
|
-
var compareMinX = node.leaf ? this.compareMinX : compareNodeMinX;
|
|
445
|
-
var compareMinY = node.leaf ? this.compareMinY : compareNodeMinY;
|
|
446
|
-
var xMargin = this._allDistMargin(node, m, M, compareMinX);
|
|
447
|
-
var yMargin = this._allDistMargin(node, m, M, compareMinY);
|
|
448
|
-
|
|
449
|
-
// if total distributions margin value is minimal for x, sort by minX,
|
|
450
|
-
// otherwise it's already sorted by minY
|
|
451
|
-
if (xMargin < yMargin) { node.children.sort(compareMinX); }
|
|
452
|
-
};
|
|
453
|
-
|
|
454
|
-
// total margin of all possible split distributions where each node is at least m full
|
|
455
|
-
RBush.prototype._allDistMargin = function _allDistMargin (node, m, M, compare) {
|
|
456
|
-
node.children.sort(compare);
|
|
457
|
-
|
|
458
|
-
var toBBox = this.toBBox;
|
|
459
|
-
var leftBBox = distBBox(node, 0, m, toBBox);
|
|
460
|
-
var rightBBox = distBBox(node, M - m, M, toBBox);
|
|
461
|
-
var margin = bboxMargin(leftBBox) + bboxMargin(rightBBox);
|
|
462
|
-
|
|
463
|
-
for (var i = m; i < M - m; i++) {
|
|
464
|
-
var child = node.children[i];
|
|
465
|
-
extend(leftBBox, node.leaf ? toBBox(child) : child);
|
|
466
|
-
margin += bboxMargin(leftBBox);
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
for (var i$1 = M - m - 1; i$1 >= m; i$1--) {
|
|
470
|
-
var child$1 = node.children[i$1];
|
|
471
|
-
extend(rightBBox, node.leaf ? toBBox(child$1) : child$1);
|
|
472
|
-
margin += bboxMargin(rightBBox);
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
return margin;
|
|
476
|
-
};
|
|
477
|
-
|
|
478
|
-
RBush.prototype._adjustParentBBoxes = function _adjustParentBBoxes (bbox, path, level) {
|
|
479
|
-
// adjust bboxes along the given tree path
|
|
480
|
-
for (var i = level; i >= 0; i--) {
|
|
481
|
-
extend(path[i], bbox);
|
|
482
|
-
}
|
|
483
|
-
};
|
|
484
|
-
|
|
485
|
-
RBush.prototype._condense = function _condense (path) {
|
|
486
|
-
// go through the path, removing empty nodes and updating bboxes
|
|
487
|
-
for (var i = path.length - 1, siblings = (void 0); i >= 0; i--) {
|
|
488
|
-
if (path[i].children.length === 0) {
|
|
489
|
-
if (i > 0) {
|
|
490
|
-
siblings = path[i - 1].children;
|
|
491
|
-
siblings.splice(siblings.indexOf(path[i]), 1);
|
|
492
|
-
|
|
493
|
-
} else { this.clear(); }
|
|
494
|
-
|
|
495
|
-
} else { calcBBox(path[i], this.toBBox); }
|
|
496
|
-
}
|
|
497
|
-
};
|
|
498
|
-
|
|
499
|
-
function findItem(item, items, equalsFn) {
|
|
500
|
-
if (!equalsFn) { return items.indexOf(item); }
|
|
501
|
-
|
|
502
|
-
for (var i = 0; i < items.length; i++) {
|
|
503
|
-
if (equalsFn(item, items[i])) { return i; }
|
|
504
|
-
}
|
|
505
|
-
return -1;
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
// calculate node's bbox from bboxes of its children
|
|
509
|
-
function calcBBox(node, toBBox) {
|
|
510
|
-
distBBox(node, 0, node.children.length, toBBox, node);
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
// min bounding rectangle of node children from k to p-1
|
|
514
|
-
function distBBox(node, k, p, toBBox, destNode) {
|
|
515
|
-
if (!destNode) { destNode = createNode(null); }
|
|
516
|
-
destNode.minX = Infinity;
|
|
517
|
-
destNode.minY = Infinity;
|
|
518
|
-
destNode.maxX = -Infinity;
|
|
519
|
-
destNode.maxY = -Infinity;
|
|
520
|
-
|
|
521
|
-
for (var i = k; i < p; i++) {
|
|
522
|
-
var child = node.children[i];
|
|
523
|
-
extend(destNode, node.leaf ? toBBox(child) : child);
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
return destNode;
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
function extend(a, b) {
|
|
530
|
-
a.minX = Math.min(a.minX, b.minX);
|
|
531
|
-
a.minY = Math.min(a.minY, b.minY);
|
|
532
|
-
a.maxX = Math.max(a.maxX, b.maxX);
|
|
533
|
-
a.maxY = Math.max(a.maxY, b.maxY);
|
|
534
|
-
return a;
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
function compareNodeMinX(a, b) { return a.minX - b.minX; }
|
|
538
|
-
function compareNodeMinY(a, b) { return a.minY - b.minY; }
|
|
539
|
-
|
|
540
|
-
function bboxArea(a) { return (a.maxX - a.minX) * (a.maxY - a.minY); }
|
|
541
|
-
function bboxMargin(a) { return (a.maxX - a.minX) + (a.maxY - a.minY); }
|
|
542
|
-
|
|
543
|
-
function enlargedArea(a, b) {
|
|
544
|
-
return (Math.max(b.maxX, a.maxX) - Math.min(b.minX, a.minX)) *
|
|
545
|
-
(Math.max(b.maxY, a.maxY) - Math.min(b.minY, a.minY));
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
function intersectionArea(a, b) {
|
|
549
|
-
var minX = Math.max(a.minX, b.minX);
|
|
550
|
-
var minY = Math.max(a.minY, b.minY);
|
|
551
|
-
var maxX = Math.min(a.maxX, b.maxX);
|
|
552
|
-
var maxY = Math.min(a.maxY, b.maxY);
|
|
553
|
-
|
|
554
|
-
return Math.max(0, maxX - minX) *
|
|
555
|
-
Math.max(0, maxY - minY);
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
function contains(a, b) {
|
|
559
|
-
return a.minX <= b.minX &&
|
|
560
|
-
a.minY <= b.minY &&
|
|
561
|
-
b.maxX <= a.maxX &&
|
|
562
|
-
b.maxY <= a.maxY;
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
function intersects(a, b) {
|
|
566
|
-
return b.minX <= a.maxX &&
|
|
567
|
-
b.minY <= a.maxY &&
|
|
568
|
-
b.maxX >= a.minX &&
|
|
569
|
-
b.maxY >= a.minY;
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
function createNode(children) {
|
|
573
|
-
return {
|
|
574
|
-
children: children,
|
|
575
|
-
height: 1,
|
|
576
|
-
leaf: true,
|
|
577
|
-
minX: Infinity,
|
|
578
|
-
minY: Infinity,
|
|
579
|
-
maxX: -Infinity,
|
|
580
|
-
maxY: -Infinity
|
|
581
|
-
};
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
// sort an array so that items come in groups of n unsorted items, with groups sorted between each other;
|
|
585
|
-
// combines selection algorithm with binary divide & conquer approach
|
|
586
|
-
|
|
587
|
-
function multiSelect(arr, left, right, n, compare) {
|
|
588
|
-
var stack = [left, right];
|
|
589
|
-
|
|
590
|
-
while (stack.length) {
|
|
591
|
-
right = stack.pop();
|
|
592
|
-
left = stack.pop();
|
|
593
|
-
|
|
594
|
-
if (right - left <= n) { continue; }
|
|
595
|
-
|
|
596
|
-
var mid = left + Math.ceil((right - left) / n / 2) * n;
|
|
597
|
-
quickselect(arr, mid, left, right, compare);
|
|
598
|
-
|
|
599
|
-
stack.push(left, mid, mid, right);
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
return RBush;
|
|
604
|
-
|
|
605
|
-
}));
|
|
606
|
-
}(rbush));
|
|
607
|
-
|
|
608
|
-
var RBush = rbush.exports;
|
|
30
|
+
/// <reference types="webxr" />
|
|
609
31
|
|
|
610
32
|
var Shape = /*#__PURE__*/function (Shape) {
|
|
611
33
|
Shape["GROUP"] = "g";
|
|
@@ -7083,7 +6505,6 @@ var DefaultStyleValueRegistry = /*#__PURE__*/function () {
|
|
|
7083
6505
|
this.runtime.CSSPropertySyntaxFactory[PropertySyntax.TRANSFORM_ORIGIN].postProcessor(object);
|
|
7084
6506
|
}
|
|
7085
6507
|
if (needUpdateGeometry) {
|
|
7086
|
-
object.geometry.dirty = true;
|
|
7087
6508
|
object.dirty(true, true);
|
|
7088
6509
|
if (!options.forceUpdateGeometry) {
|
|
7089
6510
|
this.runtime.sceneGraphService.dirtyToRoot(object);
|
|
@@ -7893,9 +7314,9 @@ var AsyncSeriesWaterfallHook = /*#__PURE__*/function () {
|
|
|
7893
7314
|
return (_this$callbacks = this.callbacks)[0].apply(_this$callbacks, _args);
|
|
7894
7315
|
case 1:
|
|
7895
7316
|
result = _context.sent;
|
|
7896
|
-
i =
|
|
7317
|
+
i = 1;
|
|
7897
7318
|
case 2:
|
|
7898
|
-
if (!(i < this.callbacks.length
|
|
7319
|
+
if (!(i < this.callbacks.length)) {
|
|
7899
7320
|
_context.next = 5;
|
|
7900
7321
|
break;
|
|
7901
7322
|
}
|
|
@@ -7974,7 +7395,7 @@ var SyncWaterfallHook = /*#__PURE__*/function () {
|
|
|
7974
7395
|
var argsArr = arguments;
|
|
7975
7396
|
/* eslint-disable-next-line prefer-spread */
|
|
7976
7397
|
var result = this.callbacks[0].apply(undefined, argsArr);
|
|
7977
|
-
for (var i =
|
|
7398
|
+
for (var i = 1; i < this.callbacks.length; i++) {
|
|
7978
7399
|
var callback = this.callbacks[i];
|
|
7979
7400
|
// @ts-ignore
|
|
7980
7401
|
result = callback(result);
|
|
@@ -9060,7 +8481,8 @@ var FederatedWheelEvent = /*#__PURE__*/function (_FederatedMouseEvent) {
|
|
|
9060
8481
|
}(FederatedMouseEvent);
|
|
9061
8482
|
|
|
9062
8483
|
/**
|
|
9063
|
-
* @
|
|
8484
|
+
* @link https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent
|
|
8485
|
+
* @link https://developer.mozilla.org/en-US/docs/Web/Events/Creating_and_triggering_events
|
|
9064
8486
|
*
|
|
9065
8487
|
* @example
|
|
9066
8488
|
const event = new CustomEvent('build', { detail: { prop1: 'xx' } });
|
|
@@ -9072,15 +8494,15 @@ var FederatedWheelEvent = /*#__PURE__*/function (_FederatedMouseEvent) {
|
|
|
9072
8494
|
circle.dispatchEvent(event);
|
|
9073
8495
|
*/
|
|
9074
8496
|
var CustomEvent = /*#__PURE__*/function (_FederatedEvent) {
|
|
9075
|
-
function CustomEvent(eventName,
|
|
8497
|
+
function CustomEvent(eventName, options) {
|
|
9076
8498
|
var _this;
|
|
9077
8499
|
_classCallCheck(this, CustomEvent);
|
|
9078
8500
|
_this = _callSuper(this, CustomEvent, [null]);
|
|
9079
8501
|
_this.type = eventName;
|
|
9080
|
-
_this.detail =
|
|
8502
|
+
_this.detail = options === null || options === void 0 ? void 0 : options.detail;
|
|
9081
8503
|
|
|
9082
8504
|
// compatible with G 3.0
|
|
9083
|
-
Object.assign(_this,
|
|
8505
|
+
Object.assign(_this, options);
|
|
9084
8506
|
return _this;
|
|
9085
8507
|
}
|
|
9086
8508
|
_inherits(CustomEvent, _FederatedEvent);
|
|
@@ -9090,7 +8512,7 @@ var CustomEvent = /*#__PURE__*/function (_FederatedEvent) {
|
|
|
9090
8512
|
/**
|
|
9091
8513
|
* Objects that can receive events and may have listeners for them.
|
|
9092
8514
|
* eg. Element, Canvas, DisplayObject
|
|
9093
|
-
* @
|
|
8515
|
+
* @docs https://developer.mozilla.org/en-US/docs/Web/API/EventTarget
|
|
9094
8516
|
*/
|
|
9095
8517
|
var EventTarget = /*#__PURE__*/function () {
|
|
9096
8518
|
function EventTarget() {
|
|
@@ -9174,7 +8596,9 @@ var EventTarget = /*#__PURE__*/function () {
|
|
|
9174
8596
|
}, {
|
|
9175
8597
|
key: "emit",
|
|
9176
8598
|
value: function emit(eventName, object) {
|
|
9177
|
-
this.dispatchEvent(new CustomEvent(eventName,
|
|
8599
|
+
this.dispatchEvent(new CustomEvent(eventName, {
|
|
8600
|
+
detail: object
|
|
8601
|
+
}));
|
|
9178
8602
|
}
|
|
9179
8603
|
}, {
|
|
9180
8604
|
key: "dispatchEventToSelf",
|
|
@@ -10591,14 +10015,15 @@ var RenderingService = /*#__PURE__*/function () {
|
|
|
10591
10015
|
}
|
|
10592
10016
|
}, {
|
|
10593
10017
|
key: "render",
|
|
10594
|
-
value: function render(
|
|
10018
|
+
value: function render(canvas, frame, rerenderCallback) {
|
|
10595
10019
|
var _this2 = this;
|
|
10020
|
+
var canvasConfig = canvas.getConfig();
|
|
10021
|
+
var renderingContext = this.context.renderingContext;
|
|
10596
10022
|
this.stats.total = 0;
|
|
10597
10023
|
this.stats.rendered = 0;
|
|
10598
10024
|
this.zIndexCounter = 0;
|
|
10599
|
-
var renderingContext = this.context.renderingContext;
|
|
10600
10025
|
this.globalRuntime.sceneGraphService.syncHierarchy(renderingContext.root);
|
|
10601
|
-
this.globalRuntime.sceneGraphService.
|
|
10026
|
+
this.globalRuntime.sceneGraphService.notifyMutationObservers(canvas);
|
|
10602
10027
|
if (renderingContext.renderReasons.size && this.inited) {
|
|
10603
10028
|
// @ts-ignore
|
|
10604
10029
|
renderingContext.dirtyRectangleRenderingDisabled = this.disableDirtyRectangleRendering();
|
|
@@ -10710,11 +10135,11 @@ var RenderingService = /*#__PURE__*/function () {
|
|
|
10710
10135
|
value: function destroy() {
|
|
10711
10136
|
this.inited = false;
|
|
10712
10137
|
this.hooks.destroy.call();
|
|
10713
|
-
this.globalRuntime.sceneGraphService.
|
|
10138
|
+
this.globalRuntime.sceneGraphService.clearMutationObserverData();
|
|
10714
10139
|
}
|
|
10715
10140
|
}, {
|
|
10716
|
-
key: "
|
|
10717
|
-
value: function
|
|
10141
|
+
key: "dirty",
|
|
10142
|
+
value: function dirty() {
|
|
10718
10143
|
// need re-render
|
|
10719
10144
|
this.context.renderingContext.renderReasons.add(RenderReason.DISPLAY_OBJECT_CHANGED);
|
|
10720
10145
|
}
|
|
@@ -10916,6 +10341,9 @@ var ElementEvent = /*#__PURE__*/function (ElementEvent) {
|
|
|
10916
10341
|
|
|
10917
10342
|
// #region Canvas
|
|
10918
10343
|
|
|
10344
|
+
/**
|
|
10345
|
+
* @deprecated https://developer.chrome.com/blog/mutation-events-deprecation
|
|
10346
|
+
*/
|
|
10919
10347
|
var MutationEvent = /*#__PURE__*/function (_FederatedEvent) {
|
|
10920
10348
|
function MutationEvent(typeArg, relatedNode, prevValue, newValue, attrName, attrChange, prevParsedValue, newParsedValue) {
|
|
10921
10349
|
var _this;
|
|
@@ -10967,9 +10395,6 @@ var $setPosition_ParentInvertMatrix = glMatrix.mat4.create();
|
|
|
10967
10395
|
var $setEulerAngles_InvParentRot = glMatrix.quat.create();
|
|
10968
10396
|
var $rotateLocal = glMatrix.quat.create();
|
|
10969
10397
|
var $rotate_ParentInvertRotation = glMatrix.quat.create();
|
|
10970
|
-
var $triggerPendingEvents_detail = {
|
|
10971
|
-
affectChildren: true
|
|
10972
|
-
};
|
|
10973
10398
|
|
|
10974
10399
|
/**
|
|
10975
10400
|
* update transform in scene graph
|
|
@@ -10979,9 +10404,7 @@ var $triggerPendingEvents_detail = {
|
|
|
10979
10404
|
var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
10980
10405
|
function DefaultSceneGraphService(runtime) {
|
|
10981
10406
|
_classCallCheck(this, DefaultSceneGraphService);
|
|
10982
|
-
|
|
10983
|
-
this.pendingEvents = new Map();
|
|
10984
|
-
this.boundsChangedEvent = new CustomEvent(ElementEvent.BOUNDS_CHANGED);
|
|
10407
|
+
this.mutationsMap = new Map();
|
|
10985
10408
|
this.displayObjectDependencyMap = new WeakMap();
|
|
10986
10409
|
this.runtime = runtime;
|
|
10987
10410
|
}
|
|
@@ -11040,7 +10463,7 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
11040
10463
|
}
|
|
11041
10464
|
if (isAttachToFragment) return;
|
|
11042
10465
|
if (isChildFragment) {
|
|
11043
|
-
this.
|
|
10466
|
+
this.dirtyFragment(child);
|
|
11044
10467
|
} else {
|
|
11045
10468
|
var transform = child.transformable;
|
|
11046
10469
|
if (transform) {
|
|
@@ -11468,22 +10891,12 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
11468
10891
|
|
|
11469
10892
|
// #endregion transform
|
|
11470
10893
|
// #region bbox ----------------------------------------------------------------
|
|
11471
|
-
}, {
|
|
11472
|
-
key: "getTransformedGeometryBounds",
|
|
11473
|
-
value: function getTransformedGeometryBounds(element) {
|
|
11474
|
-
var render = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
11475
|
-
var existedAABB = arguments.length > 2 ? arguments[2] : undefined;
|
|
11476
|
-
var bounds = this.getGeometryBounds(element, render);
|
|
11477
|
-
if (!AABB.isEmpty(bounds)) {
|
|
11478
|
-
var aabb = existedAABB || new AABB();
|
|
11479
|
-
aabb.setFromTransformedAABB(bounds, this.getWorldTransform(element));
|
|
11480
|
-
return aabb;
|
|
11481
|
-
}
|
|
11482
|
-
return null;
|
|
11483
|
-
}
|
|
11484
10894
|
|
|
11485
10895
|
/**
|
|
11486
|
-
*
|
|
10896
|
+
* Get the geometry bounds of the element itself, excluding children.
|
|
10897
|
+
*
|
|
10898
|
+
* @param element - The element to get geometry bounds for
|
|
10899
|
+
* @param render - If true, returns render bounds (including strokes, etc.); otherwise returns content bounds
|
|
11487
10900
|
*/
|
|
11488
10901
|
}, {
|
|
11489
10902
|
key: "getGeometryBounds",
|
|
@@ -11499,6 +10912,27 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
11499
10912
|
return bounds || new AABB();
|
|
11500
10913
|
}
|
|
11501
10914
|
|
|
10915
|
+
/**
|
|
10916
|
+
* Get the geometry bounds of the element itself in world space, excluding children.
|
|
10917
|
+
*
|
|
10918
|
+
* @param element - The element to get transformed geometry bounds for
|
|
10919
|
+
* @param render - If true, returns render bounds (including strokes, etc.); otherwise returns content bounds
|
|
10920
|
+
* @param existedAABB - Optional existing AABB to reuse
|
|
10921
|
+
*/
|
|
10922
|
+
}, {
|
|
10923
|
+
key: "getTransformedGeometryBounds",
|
|
10924
|
+
value: function getTransformedGeometryBounds(element) {
|
|
10925
|
+
var render = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
10926
|
+
var existedAABB = arguments.length > 2 ? arguments[2] : undefined;
|
|
10927
|
+
var bounds = this.getGeometryBounds(element, render);
|
|
10928
|
+
if (!AABB.isEmpty(bounds)) {
|
|
10929
|
+
var aabb = existedAABB || new AABB();
|
|
10930
|
+
aabb.setFromTransformedAABB(bounds, this.getWorldTransform(element));
|
|
10931
|
+
return aabb;
|
|
10932
|
+
}
|
|
10933
|
+
return null;
|
|
10934
|
+
}
|
|
10935
|
+
|
|
11502
10936
|
/**
|
|
11503
10937
|
* account for children in world space
|
|
11504
10938
|
*/
|
|
@@ -11699,12 +11133,12 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
11699
11133
|
}, {
|
|
11700
11134
|
key: "dirtyWorldTransform",
|
|
11701
11135
|
value: function dirtyWorldTransform(element, transform) {
|
|
11702
|
-
this.
|
|
11136
|
+
this.dirtyWorldInternal(element, transform);
|
|
11703
11137
|
this.dirtyToRoot(element, true);
|
|
11704
11138
|
}
|
|
11705
11139
|
}, {
|
|
11706
|
-
key: "
|
|
11707
|
-
value: function
|
|
11140
|
+
key: "dirtyWorldInternal",
|
|
11141
|
+
value: function dirtyWorldInternal(element, transform) {
|
|
11708
11142
|
var _element$ownerDocumen3,
|
|
11709
11143
|
_this2 = this;
|
|
11710
11144
|
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;
|
|
@@ -11714,7 +11148,7 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
11714
11148
|
if (!enableAttributeUpdateOptimization) {
|
|
11715
11149
|
element.childNodes.forEach(function (child) {
|
|
11716
11150
|
var childTransform = child.transformable;
|
|
11717
|
-
_this2.
|
|
11151
|
+
_this2.dirtyWorldInternal(child, childTransform);
|
|
11718
11152
|
});
|
|
11719
11153
|
}
|
|
11720
11154
|
}
|
|
@@ -11742,11 +11176,25 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
11742
11176
|
});
|
|
11743
11177
|
}
|
|
11744
11178
|
this.informDependentDisplayObjects(element);
|
|
11745
|
-
this.
|
|
11179
|
+
var mutation = this.mutationsMap.get(element);
|
|
11180
|
+
if (!mutation) {
|
|
11181
|
+
mutation = {
|
|
11182
|
+
type: 'attributes',
|
|
11183
|
+
target: element,
|
|
11184
|
+
_boundsChangeData: {
|
|
11185
|
+
affectChildren: affectChildren
|
|
11186
|
+
}
|
|
11187
|
+
};
|
|
11188
|
+
this.mutationsMap.set(element, mutation);
|
|
11189
|
+
} else {
|
|
11190
|
+
mutation._boundsChangeData = {
|
|
11191
|
+
affectChildren: mutation._boundsChangeData.affectChildren || affectChildren
|
|
11192
|
+
};
|
|
11193
|
+
}
|
|
11746
11194
|
}
|
|
11747
11195
|
}, {
|
|
11748
|
-
key: "
|
|
11749
|
-
value: function
|
|
11196
|
+
key: "dirtyFragment",
|
|
11197
|
+
value: function dirtyFragment(element) {
|
|
11750
11198
|
var _dirty3, _ref7;
|
|
11751
11199
|
var transform = element.transformable;
|
|
11752
11200
|
if (transform) {
|
|
@@ -11756,65 +11204,22 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
11756
11204
|
(_dirty3 = (_ref7 = element).dirty) === null || _dirty3 === void 0 || _dirty3.call(_ref7, true, true);
|
|
11757
11205
|
var length = element.childNodes.length;
|
|
11758
11206
|
for (var i = 0; i < length; i++) {
|
|
11759
|
-
this.
|
|
11760
|
-
}
|
|
11761
|
-
if (element.nodeName === Shape.FRAGMENT) {
|
|
11762
|
-
this.pendingEvents.set(element, false);
|
|
11207
|
+
this.dirtyFragment(element.childNodes[i]);
|
|
11763
11208
|
}
|
|
11764
11209
|
}
|
|
11765
11210
|
}, {
|
|
11766
|
-
key: "
|
|
11767
|
-
value: function
|
|
11768
|
-
var
|
|
11769
|
-
|
|
11770
|
-
var enableCancelEventPropagation;
|
|
11771
|
-
var enableAttributeUpdateOptimization;
|
|
11772
|
-
var trigger = function trigger(element, detail) {
|
|
11773
|
-
if (!element.isConnected || triggered.has(element) || element.nodeName === Shape.FRAGMENT) {
|
|
11774
|
-
return;
|
|
11775
|
-
}
|
|
11776
|
-
_this3.boundsChangedEvent.detail = detail;
|
|
11777
|
-
_this3.boundsChangedEvent.target = element;
|
|
11778
|
-
if (element.isMutationObserved) {
|
|
11779
|
-
element.dispatchEvent(_this3.boundsChangedEvent);
|
|
11780
|
-
} else {
|
|
11781
|
-
if (enableCancelEventPropagation === undefined) {
|
|
11782
|
-
var _element$ownerDocumen5;
|
|
11783
|
-
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;
|
|
11784
|
-
}
|
|
11785
|
-
element.ownerDocument.defaultView.dispatchEvent(_this3.boundsChangedEvent, true, enableCancelEventPropagation);
|
|
11786
|
-
}
|
|
11787
|
-
triggered.add(element);
|
|
11788
|
-
};
|
|
11789
|
-
this.pendingEvents.forEach(function (affectChildren, element) {
|
|
11790
|
-
if (element.nodeName === Shape.FRAGMENT) {
|
|
11791
|
-
return;
|
|
11792
|
-
}
|
|
11793
|
-
if (enableAttributeUpdateOptimization === undefined) {
|
|
11794
|
-
var _element$ownerDocumen6;
|
|
11795
|
-
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;
|
|
11796
|
-
}
|
|
11797
|
-
$triggerPendingEvents_detail.affectChildren = affectChildren;
|
|
11798
|
-
if (enableAttributeUpdateOptimization) {
|
|
11799
|
-
trigger(element, $triggerPendingEvents_detail);
|
|
11800
|
-
} else {
|
|
11801
|
-
// eslint-disable-next-line no-lonely-if
|
|
11802
|
-
if (affectChildren) {
|
|
11803
|
-
element.forEach(function (e) {
|
|
11804
|
-
trigger(e, $triggerPendingEvents_detail);
|
|
11805
|
-
});
|
|
11806
|
-
} else {
|
|
11807
|
-
trigger(element, $triggerPendingEvents_detail);
|
|
11808
|
-
}
|
|
11809
|
-
}
|
|
11211
|
+
key: "notifyMutationObservers",
|
|
11212
|
+
value: function notifyMutationObservers(canvas) {
|
|
11213
|
+
var event = new CustomEvent(ElementEvent.BOUNDS_CHANGED, {
|
|
11214
|
+
detail: Array.from(this.mutationsMap.values())
|
|
11810
11215
|
});
|
|
11811
|
-
|
|
11812
|
-
this.
|
|
11216
|
+
canvas.dispatchEvent(event, true, true);
|
|
11217
|
+
this.clearMutationObserverData();
|
|
11813
11218
|
}
|
|
11814
11219
|
}, {
|
|
11815
|
-
key: "
|
|
11816
|
-
value: function
|
|
11817
|
-
this.
|
|
11220
|
+
key: "clearMutationObserverData",
|
|
11221
|
+
value: function clearMutationObserverData() {
|
|
11222
|
+
this.mutationsMap.clear();
|
|
11818
11223
|
}
|
|
11819
11224
|
}, {
|
|
11820
11225
|
key: "updateDisplayObjectDependency",
|
|
@@ -11843,7 +11248,7 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
11843
11248
|
key: "informDependentDisplayObjects",
|
|
11844
11249
|
value: function informDependentDisplayObjects(object) {
|
|
11845
11250
|
var _object$ownerDocument,
|
|
11846
|
-
|
|
11251
|
+
_this3 = this;
|
|
11847
11252
|
var dependencyMap = this.displayObjectDependencyMap.get(object);
|
|
11848
11253
|
if (!dependencyMap) {
|
|
11849
11254
|
return;
|
|
@@ -11851,11 +11256,11 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
11851
11256
|
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;
|
|
11852
11257
|
Object.keys(dependencyMap).forEach(function (name) {
|
|
11853
11258
|
dependencyMap[name].forEach(function (target) {
|
|
11854
|
-
|
|
11855
|
-
target.dispatchEvent(new MutationEvent(ElementEvent.ATTR_MODIFIED, target,
|
|
11259
|
+
_this3.dirtyToRoot(target, true);
|
|
11260
|
+
target.dispatchEvent(new MutationEvent(ElementEvent.ATTR_MODIFIED, target, _this3, _this3, name, MutationEvent.MODIFICATION, _this3, _this3), enableCancelEventPropagation, enableCancelEventPropagation);
|
|
11856
11261
|
if (target.isCustomElement && target.isConnected) {
|
|
11857
11262
|
if (target.attributeChangedCallback) {
|
|
11858
|
-
target.attributeChangedCallback(name,
|
|
11263
|
+
target.attributeChangedCallback(name, _this3, _this3);
|
|
11859
11264
|
}
|
|
11860
11265
|
}
|
|
11861
11266
|
});
|
|
@@ -12580,6 +11985,10 @@ var Element = /*#__PURE__*/function (_Node) {
|
|
|
12580
11985
|
dirtyChildren: [],
|
|
12581
11986
|
dirtyReason: undefined
|
|
12582
11987
|
};
|
|
11988
|
+
/**
|
|
11989
|
+
* @deprecated Legacy property for RBush spatial indexing.
|
|
11990
|
+
* Will be removed in future versions.
|
|
11991
|
+
*/
|
|
12583
11992
|
_this.rBushNode = {
|
|
12584
11993
|
aabb: undefined
|
|
12585
11994
|
};
|
|
@@ -12635,16 +12044,23 @@ var Element = /*#__PURE__*/function (_Node) {
|
|
|
12635
12044
|
key: "dirty",
|
|
12636
12045
|
value:
|
|
12637
12046
|
/**
|
|
12638
|
-
*
|
|
12639
|
-
*
|
|
12047
|
+
* Marks the element as dirty, indicating it needs re-rendering or relayout.
|
|
12048
|
+
*
|
|
12049
|
+
* @param styleFlag - Whether to update style state (default: true).
|
|
12050
|
+
* When true, sets `renderable.dirty` to true.
|
|
12051
|
+
* @param layoutFlag - Optional. When provided, updates layout-related dirty flags:
|
|
12052
|
+
* - `renderable.boundsDirty`
|
|
12053
|
+
* - `renderable.renderBoundsDirty`
|
|
12054
|
+
* - `geometry.dirty`
|
|
12640
12055
|
*/
|
|
12641
12056
|
function dirty() {
|
|
12642
|
-
var
|
|
12643
|
-
var
|
|
12644
|
-
this.renderable.dirty =
|
|
12645
|
-
if (
|
|
12646
|
-
this.renderable.boundsDirty =
|
|
12647
|
-
this.renderable.renderBoundsDirty =
|
|
12057
|
+
var styleFlag = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
12058
|
+
var layoutFlag = arguments.length > 1 ? arguments[1] : undefined;
|
|
12059
|
+
this.renderable.dirty = styleFlag;
|
|
12060
|
+
if (layoutFlag !== undefined) {
|
|
12061
|
+
this.renderable.boundsDirty = layoutFlag;
|
|
12062
|
+
this.renderable.renderBoundsDirty = layoutFlag;
|
|
12063
|
+
this.geometry.dirty = layoutFlag;
|
|
12648
12064
|
}
|
|
12649
12065
|
}
|
|
12650
12066
|
}, {
|
|
@@ -13038,12 +12454,18 @@ var Element = /*#__PURE__*/function (_Node) {
|
|
|
13038
12454
|
}, {
|
|
13039
12455
|
key: "getGeometryBounds",
|
|
13040
12456
|
value: function getGeometryBounds() {
|
|
13041
|
-
|
|
12457
|
+
var render = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
12458
|
+
return runtime.sceneGraphService.getGeometryBounds(this, render);
|
|
13042
12459
|
}
|
|
12460
|
+
|
|
12461
|
+
/**
|
|
12462
|
+
* get geometry bounds in world space, not accounting for children
|
|
12463
|
+
*/
|
|
13043
12464
|
}, {
|
|
13044
|
-
key: "
|
|
13045
|
-
value: function
|
|
13046
|
-
|
|
12465
|
+
key: "getTransformedGeometryBounds",
|
|
12466
|
+
value: function getTransformedGeometryBounds() {
|
|
12467
|
+
var render = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
12468
|
+
return runtime.sceneGraphService.getTransformedGeometryBounds(this, render);
|
|
13047
12469
|
}
|
|
13048
12470
|
|
|
13049
12471
|
/**
|
|
@@ -13054,6 +12476,11 @@ var Element = /*#__PURE__*/function (_Node) {
|
|
|
13054
12476
|
value: function getBounds() {
|
|
13055
12477
|
return runtime.sceneGraphService.getBounds(this);
|
|
13056
12478
|
}
|
|
12479
|
+
}, {
|
|
12480
|
+
key: "getRenderBounds",
|
|
12481
|
+
value: function getRenderBounds() {
|
|
12482
|
+
return runtime.sceneGraphService.getBounds(this, true);
|
|
12483
|
+
}
|
|
13057
12484
|
|
|
13058
12485
|
/**
|
|
13059
12486
|
* get bounds in local space, account for children
|
|
@@ -13155,7 +12582,7 @@ var Element = /*#__PURE__*/function (_Node) {
|
|
|
13155
12582
|
*/
|
|
13156
12583
|
}, {
|
|
13157
12584
|
key: "setAttribute",
|
|
13158
|
-
value: function setAttribute(attributeName, value
|
|
12585
|
+
value: function setAttribute(attributeName, value) {
|
|
13159
12586
|
this.attributes[attributeName] = value;
|
|
13160
12587
|
}
|
|
13161
12588
|
}, {
|
|
@@ -13389,9 +12816,6 @@ var DisplayObject = /*#__PURE__*/function (_Element) {
|
|
|
13389
12816
|
|
|
13390
12817
|
// redraw at next frame
|
|
13391
12818
|
this.dirty();
|
|
13392
|
-
|
|
13393
|
-
// return;
|
|
13394
|
-
|
|
13395
12819
|
var newParsedValue = this.parsedStyle[name];
|
|
13396
12820
|
if (this.isConnected) {
|
|
13397
12821
|
attrModifiedEvent.relatedNode = this;
|
|
@@ -14958,7 +14382,7 @@ var Text = /*#__PURE__*/function (_DisplayObject) {
|
|
|
14958
14382
|
}
|
|
14959
14383
|
}]);
|
|
14960
14384
|
}(DisplayObject);
|
|
14961
|
-
Text.PARSED_STYLE_LIST = new Set([].concat(_toConsumableArray(DisplayObject.PARSED_STYLE_LIST), ['x', 'y', 'z', 'isBillboard', 'billboardRotation', 'isSizeAttenuation', 'text', 'textAlign', 'textBaseline', 'fontStyle', 'fontSize', 'fontFamily', 'fontWeight', 'fontVariant', 'lineHeight', 'letterSpacing', 'leading', 'wordWrap', 'wordWrapWidth', 'maxLines', 'textOverflow', 'isOverflowing', 'textPath', 'textDecorationLine', 'textDecorationColor', 'textDecorationStyle', 'textPathSide', 'textPathStartOffset', 'metrics', 'dx', 'dy']));
|
|
14385
|
+
Text.PARSED_STYLE_LIST = new Set([].concat(_toConsumableArray(DisplayObject.PARSED_STYLE_LIST), ['x', 'y', 'z', 'isBillboard', 'billboardRotation', 'isSizeAttenuation', 'text', 'textAlign', 'textBaseline', 'fontStyle', 'fontSize', 'fontFamily', 'fontWeight', 'fontVariant', 'lineHeight', 'letterSpacing', 'leading', 'wordWrap', 'wordWrapWidth', 'maxLines', 'textOverflow', 'isOverflowing', 'textPath', 'textDecorationLine', 'textDecorationColor', 'textDecorationStyle', 'textDecorationThickness', 'textPathSide', 'textPathStartOffset', 'metrics', 'dx', 'dy']));
|
|
14962
14386
|
|
|
14963
14387
|
/**
|
|
14964
14388
|
* canvas.customElements
|
|
@@ -15220,32 +14644,47 @@ var Document = /*#__PURE__*/function (_Node) {
|
|
|
15220
14644
|
}
|
|
15221
14645
|
|
|
15222
14646
|
/**
|
|
15223
|
-
* Picking 2D graphics
|
|
14647
|
+
* Picking 2D graphics by traversing elements and checking bounding boxes.
|
|
15224
14648
|
*/
|
|
15225
14649
|
}, {
|
|
15226
14650
|
key: "elementsFromBBox",
|
|
15227
14651
|
value: function elementsFromBBox(minX, minY, maxX, maxY) {
|
|
15228
|
-
var rBush = this.defaultView.context.rBushRoot;
|
|
15229
|
-
var rBushNodes = rBush.search({
|
|
15230
|
-
minX: minX,
|
|
15231
|
-
minY: minY,
|
|
15232
|
-
maxX: maxX,
|
|
15233
|
-
maxY: maxY
|
|
15234
|
-
});
|
|
15235
14652
|
var hitTestList = [];
|
|
15236
|
-
rBushNodes.forEach(function (_ref2) {
|
|
15237
|
-
var displayObject = _ref2.displayObject;
|
|
15238
|
-
var _displayObject$parsed = displayObject.parsedStyle.pointerEvents,
|
|
15239
|
-
pointerEvents = _displayObject$parsed === void 0 ? 'auto' : _displayObject$parsed;
|
|
15240
14653
|
|
|
15241
|
-
|
|
14654
|
+
// Traverse all elements in the document
|
|
14655
|
+
var _traverse = function traverse(node) {
|
|
14656
|
+
if (!node.isInteractive() || node.isCulled()) {
|
|
14657
|
+
return;
|
|
14658
|
+
}
|
|
14659
|
+
var _node$parsedStyle$poi = node.parsedStyle.pointerEvents,
|
|
14660
|
+
pointerEvents = _node$parsedStyle$poi === void 0 ? 'auto' : _node$parsedStyle$poi;
|
|
14661
|
+
|
|
14662
|
+
// Account for `visibility`
|
|
15242
14663
|
// @see https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events
|
|
15243
14664
|
var isVisibilityAffected = ['auto', 'visiblepainted', 'visiblefill', 'visiblestroke', 'visible'].includes(pointerEvents);
|
|
15244
|
-
if (
|
|
15245
|
-
|
|
14665
|
+
if (!isVisibilityAffected || node.isVisible()) {
|
|
14666
|
+
var bounds = node.getTransformedGeometryBounds(true);
|
|
14667
|
+
if (bounds && !AABB.isEmpty(bounds)) {
|
|
14668
|
+
if (bounds.max[0] >= minX && bounds.min[0] <= maxX && bounds.max[1] >= minY && bounds.min[1] <= maxY) {
|
|
14669
|
+
hitTestList.push(node);
|
|
14670
|
+
}
|
|
14671
|
+
}
|
|
15246
14672
|
}
|
|
15247
|
-
|
|
15248
|
-
|
|
14673
|
+
|
|
14674
|
+
// Traverse children if it's a container
|
|
14675
|
+
if (node.childNodes) {
|
|
14676
|
+
node.childNodes.forEach(function (child) {
|
|
14677
|
+
if (child instanceof DisplayObject) {
|
|
14678
|
+
_traverse(child);
|
|
14679
|
+
}
|
|
14680
|
+
});
|
|
14681
|
+
}
|
|
14682
|
+
};
|
|
14683
|
+
|
|
14684
|
+
// Start traversal from documentElement
|
|
14685
|
+
_traverse(this.documentElement);
|
|
14686
|
+
|
|
14687
|
+
// Sort by render order (z-index)
|
|
15249
14688
|
hitTestList.sort(function (a, b) {
|
|
15250
14689
|
return b.sortable.renderOrder - a.sortable.renderOrder;
|
|
15251
14690
|
});
|
|
@@ -15977,32 +15416,34 @@ var FrustumCullingStrategy = /*#__PURE__*/function () {
|
|
|
15977
15416
|
}]);
|
|
15978
15417
|
}();
|
|
15979
15418
|
|
|
15419
|
+
/**
|
|
15420
|
+
* PrepareRendererPlugin handles rendering preparation tasks
|
|
15421
|
+
* Simplified implementation focused on core rendering needs
|
|
15422
|
+
*/
|
|
15980
15423
|
var PrepareRendererPlugin = /*#__PURE__*/function () {
|
|
15981
15424
|
function PrepareRendererPlugin() {
|
|
15982
15425
|
_classCallCheck(this, PrepareRendererPlugin);
|
|
15983
|
-
this.
|
|
15426
|
+
this.mutationRecords = [];
|
|
15984
15427
|
this.isFirstTimeRendering = true;
|
|
15985
|
-
this.syncing = false;
|
|
15986
15428
|
this.isFirstTimeRenderingFinished = false;
|
|
15987
15429
|
}
|
|
15988
15430
|
return _createClass(PrepareRendererPlugin, [{
|
|
15989
15431
|
key: "apply",
|
|
15990
15432
|
value: function apply(context) {
|
|
15991
15433
|
var _this = this,
|
|
15992
|
-
_runtime$globalThis$r
|
|
15993
|
-
|
|
15994
|
-
|
|
15995
|
-
renderingService = context.renderingService,
|
|
15996
|
-
renderingContext = context.renderingContext,
|
|
15997
|
-
rBushRoot = context.rBushRoot;
|
|
15434
|
+
_runtime$globalThis$r;
|
|
15435
|
+
var renderingService = context.renderingService,
|
|
15436
|
+
renderingContext = context.renderingContext;
|
|
15998
15437
|
var canvas = renderingContext.root.ownerDocument.defaultView;
|
|
15999
|
-
this.rBush = rBushRoot;
|
|
16000
15438
|
var handleAttributeChanged = function handleAttributeChanged(e) {
|
|
16001
|
-
renderingService.
|
|
15439
|
+
renderingService.dirty();
|
|
16002
15440
|
};
|
|
16003
15441
|
var handleBoundsChanged = function handleBoundsChanged(e) {
|
|
16004
|
-
_this
|
|
16005
|
-
|
|
15442
|
+
var _this$mutationRecords;
|
|
15443
|
+
var records = e.detail;
|
|
15444
|
+
// Store mutation records for potential future processing
|
|
15445
|
+
(_this$mutationRecords = _this.mutationRecords).push.apply(_this$mutationRecords, _toConsumableArray(records));
|
|
15446
|
+
renderingService.dirty();
|
|
16006
15447
|
};
|
|
16007
15448
|
var handleMounted = function handleMounted(e) {
|
|
16008
15449
|
var object = e.target;
|
|
@@ -16012,13 +15453,10 @@ var PrepareRendererPlugin = /*#__PURE__*/function () {
|
|
|
16012
15453
|
};
|
|
16013
15454
|
var handleUnmounted = function handleUnmounted(e) {
|
|
16014
15455
|
var object = e.target;
|
|
16015
|
-
|
|
16016
|
-
|
|
16017
|
-
_this.rBush.remove(rBushNode.aabb);
|
|
16018
|
-
}
|
|
16019
|
-
_this.syncTasks["delete"](object);
|
|
15456
|
+
|
|
15457
|
+
// No spatial index cleanup needed
|
|
16020
15458
|
runtime.sceneGraphService.dirtyToRoot(object);
|
|
16021
|
-
renderingService.
|
|
15459
|
+
renderingService.dirty();
|
|
16022
15460
|
};
|
|
16023
15461
|
renderingService.hooks.init.tap(PrepareRendererPlugin.tag, function () {
|
|
16024
15462
|
canvas.addEventListener(ElementEvent.MOUNTED, handleMounted);
|
|
@@ -16031,109 +15469,20 @@ var PrepareRendererPlugin = /*#__PURE__*/function () {
|
|
|
16031
15469
|
canvas.removeEventListener(ElementEvent.UNMOUNTED, handleUnmounted);
|
|
16032
15470
|
canvas.removeEventListener(ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
16033
15471
|
canvas.removeEventListener(ElementEvent.BOUNDS_CHANGED, handleBoundsChanged);
|
|
16034
|
-
_this.
|
|
15472
|
+
_this.mutationRecords = [];
|
|
16035
15473
|
});
|
|
16036
15474
|
var ric = (_runtime$globalThis$r = runtime.globalThis.requestIdleCallback) !== null && _runtime$globalThis$r !== void 0 ? _runtime$globalThis$r : raf.bind(runtime.globalThis);
|
|
16037
|
-
var enableRICSyncRTree = ((_config$future = config.future) === null || _config$future === void 0 ? void 0 : _config$future.experimentalRICSyncRTree) === true;
|
|
16038
15475
|
renderingService.hooks.endFrame.tap(PrepareRendererPlugin.tag, function () {
|
|
16039
15476
|
if (_this.isFirstTimeRendering) {
|
|
16040
15477
|
_this.isFirstTimeRendering = false;
|
|
16041
|
-
_this.syncing = true;
|
|
16042
15478
|
ric(function () {
|
|
16043
|
-
_this.syncRTree(true);
|
|
16044
15479
|
_this.isFirstTimeRenderingFinished = true;
|
|
16045
15480
|
});
|
|
16046
|
-
} else if (enableRICSyncRTree && runtime.globalThis.requestIdleCallback && runtime.globalThis.cancelIdleCallback) {
|
|
16047
|
-
runtime.globalThis.cancelIdleCallback(_this.ricSyncRTreeId);
|
|
16048
|
-
_this.ricSyncRTreeId = runtime.globalThis.requestIdleCallback(function () {
|
|
16049
|
-
return _this.syncRTree();
|
|
16050
|
-
});
|
|
16051
|
-
} else {
|
|
16052
|
-
_this.syncRTree();
|
|
16053
15481
|
}
|
|
16054
|
-
});
|
|
16055
|
-
}
|
|
16056
|
-
}, {
|
|
16057
|
-
key: "syncNode",
|
|
16058
|
-
value: function syncNode(node) {
|
|
16059
|
-
var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
16060
|
-
if (!node.isConnected) return;
|
|
16061
|
-
var rBushNode = node.rBushNode;
|
|
16062
|
-
|
|
16063
|
-
// clear dirty node
|
|
16064
|
-
if (rBushNode.aabb) this.rBush.remove(rBushNode.aabb);
|
|
16065
|
-
var renderBounds = node.getRenderBounds();
|
|
16066
|
-
if (renderBounds) {
|
|
16067
|
-
var renderable = node.renderable;
|
|
16068
|
-
if (force) {
|
|
16069
|
-
if (!renderable.dirtyRenderBounds) {
|
|
16070
|
-
renderable.dirtyRenderBounds = new AABB();
|
|
16071
|
-
}
|
|
16072
|
-
// save last dirty aabb
|
|
16073
|
-
renderable.dirtyRenderBounds.update(renderBounds.center, renderBounds.halfExtents);
|
|
16074
|
-
}
|
|
16075
|
-
var _renderBounds$getMin = renderBounds.getMin(),
|
|
16076
|
-
_renderBounds$getMin2 = _slicedToArray(_renderBounds$getMin, 2),
|
|
16077
|
-
minX = _renderBounds$getMin2[0],
|
|
16078
|
-
minY = _renderBounds$getMin2[1];
|
|
16079
|
-
var _renderBounds$getMax = renderBounds.getMax(),
|
|
16080
|
-
_renderBounds$getMax2 = _slicedToArray(_renderBounds$getMax, 2),
|
|
16081
|
-
maxX = _renderBounds$getMax2[0],
|
|
16082
|
-
maxY = _renderBounds$getMax2[1];
|
|
16083
|
-
if (!rBushNode.aabb) {
|
|
16084
|
-
rBushNode.aabb = {};
|
|
16085
|
-
}
|
|
16086
|
-
rBushNode.aabb.displayObject = node;
|
|
16087
|
-
rBushNode.aabb.minX = minX;
|
|
16088
|
-
rBushNode.aabb.minY = minY;
|
|
16089
|
-
rBushNode.aabb.maxX = maxX;
|
|
16090
|
-
rBushNode.aabb.maxY = maxY;
|
|
16091
|
-
}
|
|
16092
|
-
if (rBushNode.aabb) {
|
|
16093
|
-
// TODO: NaN occurs when width/height of Rect is 0
|
|
16094
|
-
if (!isNaN(rBushNode.aabb.maxX) && !isNaN(rBushNode.aabb.maxX) && !isNaN(rBushNode.aabb.minX) && !isNaN(rBushNode.aabb.minY)) {
|
|
16095
|
-
return rBushNode.aabb;
|
|
16096
|
-
}
|
|
16097
|
-
}
|
|
16098
|
-
}
|
|
16099
|
-
}, {
|
|
16100
|
-
key: "syncRTree",
|
|
16101
|
-
value: function syncRTree() {
|
|
16102
|
-
var _this2 = this;
|
|
16103
|
-
var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
16104
|
-
if (!force && (this.syncing || this.syncTasks.size === 0)) {
|
|
16105
|
-
return;
|
|
16106
|
-
}
|
|
16107
|
-
this.syncing = true;
|
|
16108
|
-
|
|
16109
|
-
// bounds changed, need re-inserting its children
|
|
16110
|
-
var bulk = [];
|
|
16111
|
-
var synced = new Set();
|
|
16112
|
-
var sync = function sync(node) {
|
|
16113
|
-
if (!synced.has(node) && node.renderable) {
|
|
16114
|
-
var aabb = _this2.syncNode(node, force);
|
|
16115
|
-
if (aabb) {
|
|
16116
|
-
bulk.push(aabb);
|
|
16117
|
-
synced.add(node);
|
|
16118
|
-
}
|
|
16119
|
-
}
|
|
16120
|
-
};
|
|
16121
|
-
this.syncTasks.forEach(function (affectChildren, node) {
|
|
16122
|
-
if (affectChildren) {
|
|
16123
|
-
node.forEach(sync);
|
|
16124
|
-
}
|
|
16125
|
-
var parent = node;
|
|
16126
|
-
while (parent) {
|
|
16127
|
-
sync(parent);
|
|
16128
|
-
parent = parent.parentElement;
|
|
16129
|
-
}
|
|
16130
|
-
});
|
|
16131
15482
|
|
|
16132
|
-
|
|
16133
|
-
|
|
16134
|
-
|
|
16135
|
-
bulk.length = 0;
|
|
16136
|
-
this.syncing = false;
|
|
15483
|
+
// Clear mutation records after each frame
|
|
15484
|
+
_this.mutationRecords = [];
|
|
15485
|
+
});
|
|
16137
15486
|
}
|
|
16138
15487
|
}]);
|
|
16139
15488
|
}();
|
|
@@ -16432,10 +15781,7 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
16432
15781
|
this.getContextService().destroy();
|
|
16433
15782
|
|
|
16434
15783
|
// clear root after render service destroyed
|
|
16435
|
-
|
|
16436
|
-
// clear rbush
|
|
16437
|
-
this.context.rBushRoot.clear();
|
|
16438
|
-
}
|
|
15784
|
+
|
|
16439
15785
|
if (!skipTriggerEvent) {
|
|
16440
15786
|
this.dispatchEvent(new CustomEvent(CanvasEvent.AFTER_DESTROY), enableCancelEventPropagation, enableCancelEventPropagation);
|
|
16441
15787
|
}
|
|
@@ -16535,7 +15881,6 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
16535
15881
|
value: function render(frame) {
|
|
16536
15882
|
var _this$getConfig$futur2,
|
|
16537
15883
|
_this4 = this;
|
|
16538
|
-
// console.log('render ----------------------');
|
|
16539
15884
|
if (frame) {
|
|
16540
15885
|
beforeRenderEvent.detail = frame;
|
|
16541
15886
|
afterRenderEvent.detail = frame;
|
|
@@ -16543,7 +15888,7 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
16543
15888
|
var enableCancelEventPropagation = ((_this$getConfig$futur2 = this.getConfig().future) === null || _this$getConfig$futur2 === void 0 ? void 0 : _this$getConfig$futur2.experimentalCancelEventPropagation) === true;
|
|
16544
15889
|
this.dispatchEvent(beforeRenderEvent, enableCancelEventPropagation, enableCancelEventPropagation);
|
|
16545
15890
|
var renderingService = this.getRenderingService();
|
|
16546
|
-
renderingService.render(this
|
|
15891
|
+
renderingService.render(this, frame, function () {
|
|
16547
15892
|
// trigger actual rerender event
|
|
16548
15893
|
// @see https://github.com/antvis/G/issues/1268
|
|
16549
15894
|
_this4.dispatchEvent(rerenderEvent, enableCancelEventPropagation, enableCancelEventPropagation);
|
|
@@ -16573,9 +15918,6 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
16573
15918
|
this.inited = false;
|
|
16574
15919
|
this.readyPromise = undefined;
|
|
16575
15920
|
|
|
16576
|
-
// FIXME: should re-create here?
|
|
16577
|
-
this.context.rBushRoot = new RBush();
|
|
16578
|
-
|
|
16579
15921
|
// reset rendering plugins
|
|
16580
15922
|
this.context.renderingPlugins = [];
|
|
16581
15923
|
this.context.renderingPlugins.push(new EventPlugin(), new PrepareRendererPlugin(),
|
|
@@ -16863,7 +16205,6 @@ exports.Polygon = Polygon;
|
|
|
16863
16205
|
exports.Polyline = Polyline;
|
|
16864
16206
|
exports.PolylineUpdater = PolylineUpdater;
|
|
16865
16207
|
exports.PropertySyntax = PropertySyntax;
|
|
16866
|
-
exports.RBush = RBush;
|
|
16867
16208
|
exports.Rect = Rect;
|
|
16868
16209
|
exports.RectUpdater = RectUpdater;
|
|
16869
16210
|
exports.Rectangle = Rectangle;
|