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