@antv/g-lite 2.0.8 → 2.0.10-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Canvas.d.ts +0 -1
- package/dist/css/cssom/CSSMathOperator.d.ts +1 -1
- package/dist/css/cssom/CSSNumericValue.d.ts +0 -1
- package/dist/css/cssom/CSSStyleValue.d.ts +3 -3
- package/dist/css/parser/transform.d.ts +3 -2
- package/dist/display-objects/HTML.d.ts +4 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +220 -139
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +220 -138
- package/dist/index.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/dist/plugins/PrepareRendererPlugin.d.ts +0 -1
- package/dist/preset.d.ts +1 -0
- package/dist/services/RenderingService.d.ts +6 -1
- package/dist/services/SceneGraphService.d.ts +3 -1
- package/dist/services/aabb/HTMLUpdater.d.ts +10 -0
- package/dist/services/aabb/index.d.ts +1 -0
- package/dist/services/interfaces.d.ts +1 -1
- package/dist/types.d.ts +61 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var glMatrix = require('gl-matrix');
|
|
3
4
|
var tslib = require('tslib');
|
|
4
5
|
var EventEmitter = require('eventemitter3');
|
|
5
|
-
var glMatrix = require('gl-matrix');
|
|
6
6
|
var util = require('@antv/util');
|
|
7
7
|
var d3 = require('d3-color');
|
|
8
8
|
var gMath = require('@antv/g-math');
|
|
@@ -26,6 +26,8 @@ function _interopNamespaceDefault(e) {
|
|
|
26
26
|
|
|
27
27
|
var d3__namespace = /*#__PURE__*/_interopNamespaceDefault(d3);
|
|
28
28
|
|
|
29
|
+
glMatrix.glMatrix.setMatrixArrayType(Array);
|
|
30
|
+
|
|
29
31
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
30
32
|
|
|
31
33
|
var rbush = {exports: {}};
|
|
@@ -662,7 +664,7 @@ var AbstractRenderer = /** @class */ (function () {
|
|
|
662
664
|
/**
|
|
663
665
|
* enable dirty rectangle rendering by default
|
|
664
666
|
*/
|
|
665
|
-
enableDirtyRectangleRendering: true, enableDirtyRectangleRenderingDebug: false, enableSizeAttenuation: true }, config);
|
|
667
|
+
enableDirtyRectangleRendering: true, enableDirtyRectangleRenderingDebug: false, enableSizeAttenuation: true, imageSmoothingEnabled: true, imageSmoothingQuality: 'high' }, config);
|
|
666
668
|
}
|
|
667
669
|
AbstractRenderer.prototype.registerPlugin = function (plugin) {
|
|
668
670
|
var index = this.plugins.findIndex(function (p) { return p === plugin; });
|
|
@@ -3127,25 +3129,25 @@ var CSSUnitValue = /** @class */ (function (_super) {
|
|
|
3127
3129
|
case exports.UnitType.kSeconds:
|
|
3128
3130
|
// case UnitType.kHertz:
|
|
3129
3131
|
// case UnitType.kKilohertz:
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
}
|
|
3141
|
-
else {
|
|
3142
|
-
text = value + (unit_1 || '');
|
|
3143
|
-
}
|
|
3132
|
+
// case UnitType.kContainerMax: { // case UnitType.kContainerMin: // case UnitType.kContainerBlockSize: // case UnitType.kContainerInlineSize: // case UnitType.kContainerHeight: // case UnitType.kContainerWidth: // case UnitType.kDynamicViewportMax: // case UnitType.kDynamicViewportMin: // case UnitType.kDynamicViewportBlockSize: // case UnitType.kDynamicViewportInlineSize: // case UnitType.kDynamicViewportHeight: // case UnitType.kDynamicViewportWidth: // case UnitType.kLargeViewportMax: // case UnitType.kLargeViewportMin: // case UnitType.kLargeViewportBlockSize: // case UnitType.kLargeViewportInlineSize: // case UnitType.kLargeViewportHeight: // case UnitType.kLargeViewportWidth: // case UnitType.kSmallViewportMax: // case UnitType.kSmallViewportMin: // case UnitType.kSmallViewportBlockSize: // case UnitType.kSmallViewportInlineSize: // case UnitType.kSmallViewportHeight: // case UnitType.kSmallViewportWidth: // case UnitType.kViewportMax: // case UnitType.kViewportMin: // case UnitType.kViewportBlockSize: // case UnitType.kViewportInlineSize: // case UnitType.kViewportHeight: // case UnitType.kViewportWidth: // case UnitType.kFraction:
|
|
3133
|
+
case exports.UnitType.kTurns: {
|
|
3134
|
+
var kMinInteger = -999999;
|
|
3135
|
+
var kMaxInteger = 999999;
|
|
3136
|
+
var value = this.value;
|
|
3137
|
+
var unit = unitTypeToString(this.unit);
|
|
3138
|
+
if (value < kMinInteger || value > kMaxInteger) {
|
|
3139
|
+
var unit_1 = unitTypeToString(this.unit);
|
|
3140
|
+
if (!Number.isFinite(value) || Number.isNaN(value)) {
|
|
3141
|
+
text = formatInfinityOrNaN(value, unit_1);
|
|
3144
3142
|
}
|
|
3145
3143
|
else {
|
|
3146
|
-
text =
|
|
3144
|
+
text = value + (unit_1 || '');
|
|
3147
3145
|
}
|
|
3148
3146
|
}
|
|
3147
|
+
else {
|
|
3148
|
+
text = "".concat(value).concat(unit);
|
|
3149
|
+
}
|
|
3150
|
+
}
|
|
3149
3151
|
}
|
|
3150
3152
|
result += text;
|
|
3151
3153
|
return result;
|
|
@@ -3153,7 +3155,6 @@ var CSSUnitValue = /** @class */ (function (_super) {
|
|
|
3153
3155
|
return CSSUnitValue;
|
|
3154
3156
|
}(CSSStyleValue));
|
|
3155
3157
|
var Opx = new CSSUnitValue(0, 'px');
|
|
3156
|
-
new CSSUnitValue(1, 'px');
|
|
3157
3158
|
var Odeg = new CSSUnitValue(0, 'deg');
|
|
3158
3159
|
|
|
3159
3160
|
/**
|
|
@@ -5183,6 +5184,7 @@ function mergePoints(left, right) {
|
|
|
5183
5184
|
}
|
|
5184
5185
|
|
|
5185
5186
|
var _ = null;
|
|
5187
|
+
var TRANSFORM_REGEXP = /\s*(\w+)\(([^)]*)\)/g;
|
|
5186
5188
|
function cast(pattern) {
|
|
5187
5189
|
return function (contents) {
|
|
5188
5190
|
var i = 0;
|
|
@@ -5201,48 +5203,75 @@ var transformFunctions = {
|
|
|
5201
5203
|
matrix: ['NNNNNN', [_, _, 0, 0, _, _, 0, 0, 0, 0, 1, 0, _, _, 0, 1], id],
|
|
5202
5204
|
matrix3d: ['NNNNNNNNNNNNNNNN', id],
|
|
5203
5205
|
rotate: ['A'],
|
|
5204
|
-
|
|
5205
|
-
|
|
5206
|
-
|
|
5206
|
+
rotateX: ['A'],
|
|
5207
|
+
rotateY: ['A'],
|
|
5208
|
+
rotateZ: ['A'],
|
|
5207
5209
|
rotate3d: ['NNNA'],
|
|
5208
5210
|
perspective: ['L'],
|
|
5209
5211
|
scale: ['Nn', cast([_, _, new CSSUnitValue(1)]), id],
|
|
5210
|
-
|
|
5212
|
+
scaleX: [
|
|
5211
5213
|
'N',
|
|
5212
5214
|
cast([_, new CSSUnitValue(1), new CSSUnitValue(1)]),
|
|
5213
5215
|
cast([_, new CSSUnitValue(1)]),
|
|
5214
5216
|
],
|
|
5215
|
-
|
|
5217
|
+
scaleY: [
|
|
5216
5218
|
'N',
|
|
5217
5219
|
cast([new CSSUnitValue(1), _, new CSSUnitValue(1)]),
|
|
5218
5220
|
cast([new CSSUnitValue(1), _]),
|
|
5219
5221
|
],
|
|
5220
|
-
|
|
5222
|
+
scaleZ: ['N', cast([new CSSUnitValue(1), new CSSUnitValue(1), _])],
|
|
5221
5223
|
scale3d: ['NNN', id],
|
|
5222
5224
|
skew: ['Aa', null, id],
|
|
5223
|
-
|
|
5224
|
-
|
|
5225
|
+
skewX: ['A', null, cast([_, Odeg])],
|
|
5226
|
+
skewY: ['A', null, cast([Odeg, _])],
|
|
5225
5227
|
translate: ['Tt', cast([_, _, Opx]), id],
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
|
|
5228
|
+
translateX: ['T', cast([_, Opx, Opx]), cast([_, Opx])],
|
|
5229
|
+
translateY: ['T', cast([Opx, _, Opx]), cast([Opx, _])],
|
|
5230
|
+
translateZ: ['L', cast([Opx, Opx, _])],
|
|
5229
5231
|
translate3d: ['TTL', id],
|
|
5230
5232
|
};
|
|
5233
|
+
function parseArrayTransform(transform) {
|
|
5234
|
+
var result = [];
|
|
5235
|
+
var length = transform.length;
|
|
5236
|
+
for (var i = 0; i < length; i++) {
|
|
5237
|
+
var item = transform[i];
|
|
5238
|
+
var name_1 = item[0];
|
|
5239
|
+
var args = item.slice(1);
|
|
5240
|
+
// infer default value
|
|
5241
|
+
if (name_1 === 'translate' || name_1 === 'skew') {
|
|
5242
|
+
if (args.length === 1)
|
|
5243
|
+
args.push(0);
|
|
5244
|
+
}
|
|
5245
|
+
else if (name_1 === 'scale') {
|
|
5246
|
+
if (args.length === 1)
|
|
5247
|
+
args.push(args[0]);
|
|
5248
|
+
}
|
|
5249
|
+
var functionData = transformFunctions[name_1];
|
|
5250
|
+
if (!functionData)
|
|
5251
|
+
return [];
|
|
5252
|
+
var parsedArgs = args.map(function (value) { return getOrCreateUnitValue(value); });
|
|
5253
|
+
result.push({ t: name_1, d: parsedArgs });
|
|
5254
|
+
}
|
|
5255
|
+
return result;
|
|
5256
|
+
}
|
|
5231
5257
|
/**
|
|
5232
5258
|
* none
|
|
5233
5259
|
* scale(1) scale(1, 2)
|
|
5234
5260
|
* scaleX(1)
|
|
5235
5261
|
*/
|
|
5236
|
-
function parseTransform(
|
|
5237
|
-
|
|
5238
|
-
|
|
5262
|
+
function parseTransform(transform) {
|
|
5263
|
+
if (Array.isArray(transform)) {
|
|
5264
|
+
return parseArrayTransform(transform);
|
|
5265
|
+
}
|
|
5266
|
+
transform = (transform || 'none').trim();
|
|
5267
|
+
if (transform === 'none') {
|
|
5239
5268
|
return [];
|
|
5240
5269
|
}
|
|
5241
|
-
var transformRegExp = /\s*(\w+)\(([^)]*)\)/g;
|
|
5242
5270
|
var result = [];
|
|
5243
5271
|
var match;
|
|
5244
5272
|
var prevLastIndex = 0;
|
|
5245
|
-
|
|
5273
|
+
TRANSFORM_REGEXP.lastIndex = 0;
|
|
5274
|
+
while ((match = TRANSFORM_REGEXP.exec(transform))) {
|
|
5246
5275
|
if (match.index !== prevLastIndex) {
|
|
5247
5276
|
return [];
|
|
5248
5277
|
}
|
|
@@ -5289,22 +5318,24 @@ function parseTransform(string) {
|
|
|
5289
5318
|
parsedArgs.push(parsedArg);
|
|
5290
5319
|
}
|
|
5291
5320
|
result.push({ t: functionName, d: parsedArgs }); // { t: scale, d: [1, 2] }
|
|
5292
|
-
if (
|
|
5321
|
+
if (TRANSFORM_REGEXP.lastIndex === transform.length) {
|
|
5293
5322
|
return result;
|
|
5294
5323
|
}
|
|
5295
5324
|
}
|
|
5296
5325
|
return [];
|
|
5297
5326
|
}
|
|
5298
|
-
function parseTransformUnmemoize(
|
|
5299
|
-
|
|
5300
|
-
|
|
5327
|
+
function parseTransformUnmemoize(transform) {
|
|
5328
|
+
if (Array.isArray(transform)) {
|
|
5329
|
+
return parseArrayTransform(transform);
|
|
5330
|
+
}
|
|
5331
|
+
transform = (transform || 'none').trim();
|
|
5332
|
+
if (transform === 'none') {
|
|
5301
5333
|
return [];
|
|
5302
5334
|
}
|
|
5303
|
-
var transformRegExp = /\s*(\w+)\(([^)]*)\)/g;
|
|
5304
5335
|
var result = [];
|
|
5305
5336
|
var match;
|
|
5306
5337
|
var prevLastIndex = 0;
|
|
5307
|
-
while ((match =
|
|
5338
|
+
while ((match = TRANSFORM_REGEXP.exec(transform))) {
|
|
5308
5339
|
if (match.index !== prevLastIndex) {
|
|
5309
5340
|
return [];
|
|
5310
5341
|
}
|
|
@@ -5351,7 +5382,7 @@ function parseTransformUnmemoize(string) {
|
|
|
5351
5382
|
parsedArgs.push(parsedArg);
|
|
5352
5383
|
}
|
|
5353
5384
|
result.push({ t: functionName, d: parsedArgs }); // { t: scale, d: [1, 2] }
|
|
5354
|
-
if (
|
|
5385
|
+
if (TRANSFORM_REGEXP.lastIndex === transform.length) {
|
|
5355
5386
|
return result;
|
|
5356
5387
|
}
|
|
5357
5388
|
}
|
|
@@ -5363,7 +5394,7 @@ function convertItemToMatrix(item) {
|
|
|
5363
5394
|
var z;
|
|
5364
5395
|
var angle;
|
|
5365
5396
|
switch (item.t) {
|
|
5366
|
-
case '
|
|
5397
|
+
case 'rotateX':
|
|
5367
5398
|
angle = deg2rad(convertAngleUnit(item.d[0]));
|
|
5368
5399
|
return [
|
|
5369
5400
|
1,
|
|
@@ -5383,7 +5414,7 @@ function convertItemToMatrix(item) {
|
|
|
5383
5414
|
0,
|
|
5384
5415
|
1,
|
|
5385
5416
|
];
|
|
5386
|
-
case '
|
|
5417
|
+
case 'rotateY':
|
|
5387
5418
|
angle = deg2rad(convertAngleUnit(item.d[0]));
|
|
5388
5419
|
return [
|
|
5389
5420
|
Math.cos(angle),
|
|
@@ -5404,7 +5435,7 @@ function convertItemToMatrix(item) {
|
|
|
5404
5435
|
1,
|
|
5405
5436
|
];
|
|
5406
5437
|
case 'rotate':
|
|
5407
|
-
case '
|
|
5438
|
+
case 'rotateZ':
|
|
5408
5439
|
angle = deg2rad(convertAngleUnit(item.d[0]));
|
|
5409
5440
|
return [
|
|
5410
5441
|
Math.cos(angle),
|
|
@@ -5481,11 +5512,11 @@ function convertItemToMatrix(item) {
|
|
|
5481
5512
|
0,
|
|
5482
5513
|
1,
|
|
5483
5514
|
];
|
|
5484
|
-
case '
|
|
5515
|
+
case 'scaleX':
|
|
5485
5516
|
return [item.d[0].value, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
|
|
5486
|
-
case '
|
|
5517
|
+
case 'scaleY':
|
|
5487
5518
|
return [1, 0, 0, 0, 0, item.d[0].value, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
|
|
5488
|
-
case '
|
|
5519
|
+
case 'scaleZ':
|
|
5489
5520
|
return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, item.d[0].value, 0, 0, 0, 0, 1];
|
|
5490
5521
|
case 'scale3d':
|
|
5491
5522
|
return [
|
|
@@ -5527,10 +5558,10 @@ function convertItemToMatrix(item) {
|
|
|
5527
5558
|
0,
|
|
5528
5559
|
1,
|
|
5529
5560
|
];
|
|
5530
|
-
case '
|
|
5561
|
+
case 'skewX':
|
|
5531
5562
|
angle = deg2rad(convertAngleUnit(item.d[0]));
|
|
5532
5563
|
return [1, 0, 0, 0, Math.tan(angle), 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
|
|
5533
|
-
case '
|
|
5564
|
+
case 'skewY':
|
|
5534
5565
|
angle = deg2rad(convertAngleUnit(item.d[0]));
|
|
5535
5566
|
return [1, Math.tan(angle), 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
|
|
5536
5567
|
case 'translate':
|
|
@@ -5538,13 +5569,13 @@ function convertItemToMatrix(item) {
|
|
|
5538
5569
|
x = convertPercentUnit(item.d[0], 0, null) || 0;
|
|
5539
5570
|
y = convertPercentUnit(item.d[1], 0, null) || 0;
|
|
5540
5571
|
return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, x, y, 0, 1];
|
|
5541
|
-
case '
|
|
5572
|
+
case 'translateX':
|
|
5542
5573
|
x = convertPercentUnit(item.d[0], 0, null) || 0;
|
|
5543
5574
|
return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, x, 0, 0, 1];
|
|
5544
|
-
case '
|
|
5575
|
+
case 'translateY':
|
|
5545
5576
|
y = convertPercentUnit(item.d[0], 0, null) || 0;
|
|
5546
5577
|
return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, y, 0, 1];
|
|
5547
|
-
case '
|
|
5578
|
+
case 'translateZ':
|
|
5548
5579
|
z = convertPercentUnit(item.d[0], 0, null) || 0;
|
|
5549
5580
|
return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, z, 1];
|
|
5550
5581
|
case 'translate3d':
|
|
@@ -5785,13 +5816,13 @@ function quat(fromQ, toQ, f) {
|
|
|
5785
5816
|
}
|
|
5786
5817
|
return quat;
|
|
5787
5818
|
}
|
|
5788
|
-
//
|
|
5819
|
+
// scaleX/Y/Z -> scale
|
|
5789
5820
|
function typeTo2D(type) {
|
|
5790
|
-
return type.replace(/[
|
|
5821
|
+
return type.replace(/[XY]/, '');
|
|
5791
5822
|
}
|
|
5792
|
-
//
|
|
5823
|
+
// scaleX/Y/Z -> scale3d
|
|
5793
5824
|
function typeTo3D(type) {
|
|
5794
|
-
return type.replace(/(
|
|
5825
|
+
return type.replace(/(X|Y|Z|3d)?$/, '3d');
|
|
5795
5826
|
}
|
|
5796
5827
|
var isMatrixOrPerspective = function (lt, rt) {
|
|
5797
5828
|
return ((lt === 'perspective' && rt === 'perspective') ||
|
|
@@ -7925,15 +7956,15 @@ function parsedTransformToMat4(transform, object) {
|
|
|
7925
7956
|
];
|
|
7926
7957
|
glMatrix.mat4.fromScaling(tmpMat2, [newScale[0], newScale[1], 1]);
|
|
7927
7958
|
}
|
|
7928
|
-
else if (t === '
|
|
7959
|
+
else if (t === 'scaleX') {
|
|
7929
7960
|
var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return Math.max(s.value, SCALE_EPSILON); })) || [1];
|
|
7930
7961
|
glMatrix.mat4.fromScaling(tmpMat2, [newScale[0], 1, 1]);
|
|
7931
7962
|
}
|
|
7932
|
-
else if (t === '
|
|
7963
|
+
else if (t === 'scaleY') {
|
|
7933
7964
|
var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return Math.max(s.value, SCALE_EPSILON); })) || [1];
|
|
7934
7965
|
glMatrix.mat4.fromScaling(tmpMat2, [1, newScale[0], 1]);
|
|
7935
7966
|
}
|
|
7936
|
-
else if (t === '
|
|
7967
|
+
else if (t === 'scaleZ') {
|
|
7937
7968
|
var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return Math.max(s.value, SCALE_EPSILON); })) || [1];
|
|
7938
7969
|
glMatrix.mat4.fromScaling(tmpMat2, [1, 1, newScale[0]]);
|
|
7939
7970
|
}
|
|
@@ -7951,15 +7982,15 @@ function parsedTransformToMat4(transform, object) {
|
|
|
7951
7982
|
0,
|
|
7952
7983
|
]);
|
|
7953
7984
|
}
|
|
7954
|
-
else if (t === '
|
|
7985
|
+
else if (t === 'translateX') {
|
|
7955
7986
|
var newTranslation = d || [Opx];
|
|
7956
7987
|
glMatrix.mat4.fromTranslation(tmpMat2, [newTranslation[0].value, 0, 0]);
|
|
7957
7988
|
}
|
|
7958
|
-
else if (t === '
|
|
7989
|
+
else if (t === 'translateY') {
|
|
7959
7990
|
var newTranslation = d || [Opx];
|
|
7960
7991
|
glMatrix.mat4.fromTranslation(tmpMat2, [0, newTranslation[0].value, 0]);
|
|
7961
7992
|
}
|
|
7962
|
-
else if (t === '
|
|
7993
|
+
else if (t === 'translateZ') {
|
|
7963
7994
|
var newTranslation = d || [Opx];
|
|
7964
7995
|
glMatrix.mat4.fromTranslation(tmpMat2, [0, 0, newTranslation[0].value]);
|
|
7965
7996
|
}
|
|
@@ -7975,15 +8006,15 @@ function parsedTransformToMat4(transform, object) {
|
|
|
7975
8006
|
var newAngles = d || [Odeg];
|
|
7976
8007
|
glMatrix.mat4.fromZRotation(tmpMat2, deg2rad(convertAngleUnit(newAngles[0])));
|
|
7977
8008
|
}
|
|
7978
|
-
else if (t === '
|
|
8009
|
+
else if (t === 'rotateX') {
|
|
7979
8010
|
var newAngles = d || [Odeg];
|
|
7980
8011
|
glMatrix.mat4.fromXRotation(tmpMat2, deg2rad(convertAngleUnit(newAngles[0])));
|
|
7981
8012
|
}
|
|
7982
|
-
else if (t === '
|
|
8013
|
+
else if (t === 'rotateY') {
|
|
7983
8014
|
var newAngles = d || [Odeg];
|
|
7984
8015
|
glMatrix.mat4.fromYRotation(tmpMat2, deg2rad(convertAngleUnit(newAngles[0])));
|
|
7985
8016
|
}
|
|
7986
|
-
else if (t === '
|
|
8017
|
+
else if (t === 'rotateZ') {
|
|
7987
8018
|
var newAngles = d || [Odeg];
|
|
7988
8019
|
glMatrix.mat4.fromZRotation(tmpMat2, deg2rad(convertAngleUnit(newAngles[0])));
|
|
7989
8020
|
}
|
|
@@ -7999,11 +8030,11 @@ function parsedTransformToMat4(transform, object) {
|
|
|
7999
8030
|
var newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [0, 0];
|
|
8000
8031
|
createSkewMatrix(tmpMat2, deg2rad(newSkew[0]), deg2rad(newSkew[1]));
|
|
8001
8032
|
}
|
|
8002
|
-
else if (t === '
|
|
8033
|
+
else if (t === 'skewX') {
|
|
8003
8034
|
var newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [0];
|
|
8004
8035
|
createSkewMatrix(tmpMat2, deg2rad(newSkew[0]), 0);
|
|
8005
8036
|
}
|
|
8006
|
-
else if (t === '
|
|
8037
|
+
else if (t === 'skewY') {
|
|
8007
8038
|
var newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [0];
|
|
8008
8039
|
createSkewMatrix(tmpMat2, 0, deg2rad(newSkew[0]));
|
|
8009
8040
|
}
|
|
@@ -8362,6 +8393,21 @@ var GroupUpdater = /** @class */ (function () {
|
|
|
8362
8393
|
return GroupUpdater;
|
|
8363
8394
|
}());
|
|
8364
8395
|
|
|
8396
|
+
var HTMLUpdater = /** @class */ (function () {
|
|
8397
|
+
function HTMLUpdater() {
|
|
8398
|
+
}
|
|
8399
|
+
HTMLUpdater.prototype.update = function (parsedStyle, object) {
|
|
8400
|
+
var _a = parsedStyle.x, x = _a === void 0 ? 0 : _a, _b = parsedStyle.y, y = _b === void 0 ? 0 : _b, _c = parsedStyle.width, width = _c === void 0 ? 0 : _c, _d = parsedStyle.height, height = _d === void 0 ? 0 : _d;
|
|
8401
|
+
return {
|
|
8402
|
+
cx: x + width / 2,
|
|
8403
|
+
cy: y + height / 2,
|
|
8404
|
+
hwidth: width / 2,
|
|
8405
|
+
hheight: height / 2,
|
|
8406
|
+
};
|
|
8407
|
+
};
|
|
8408
|
+
return HTMLUpdater;
|
|
8409
|
+
}());
|
|
8410
|
+
|
|
8365
8411
|
function isFederatedEvent(value) {
|
|
8366
8412
|
return !!value.type;
|
|
8367
8413
|
}
|
|
@@ -10078,6 +10124,12 @@ var RenderingService = /** @class */ (function () {
|
|
|
10078
10124
|
*/
|
|
10079
10125
|
rendered: 0,
|
|
10080
10126
|
};
|
|
10127
|
+
/**
|
|
10128
|
+
* frame counter
|
|
10129
|
+
* - 1 - init root container
|
|
10130
|
+
* - 2 - user first frame
|
|
10131
|
+
*/
|
|
10132
|
+
this.frame = 0;
|
|
10081
10133
|
this.zIndexCounter = 0;
|
|
10082
10134
|
this.hooks = {
|
|
10083
10135
|
/**
|
|
@@ -10170,9 +10222,12 @@ var RenderingService = /** @class */ (function () {
|
|
|
10170
10222
|
this.stats.total = 0;
|
|
10171
10223
|
this.stats.rendered = 0;
|
|
10172
10224
|
this.zIndexCounter = 0;
|
|
10225
|
+
this.frame++;
|
|
10173
10226
|
var renderingContext = this.context.renderingContext;
|
|
10174
10227
|
this.globalRuntime.sceneGraphService.syncHierarchy(renderingContext.root);
|
|
10175
|
-
this.
|
|
10228
|
+
if (this.frame > 2) {
|
|
10229
|
+
this.globalRuntime.sceneGraphService.triggerPendingEvents(this.frame === 3 ? renderingContext.root : undefined);
|
|
10230
|
+
}
|
|
10176
10231
|
if (renderingContext.renderReasons.size && this.inited) {
|
|
10177
10232
|
// @ts-ignore
|
|
10178
10233
|
renderingContext.dirtyRectangleRenderingDisabled =
|
|
@@ -10477,6 +10532,19 @@ function markRenderableDirty(e) {
|
|
|
10477
10532
|
}
|
|
10478
10533
|
}
|
|
10479
10534
|
var reparentEvent = new MutationEvent(exports.ElementEvent.REPARENT, null, '', '', '', 0, '', '');
|
|
10535
|
+
var EPSILON = 0.000001;
|
|
10536
|
+
/**
|
|
10537
|
+
* an optimized version of gl-matrix's equals
|
|
10538
|
+
*/
|
|
10539
|
+
function equals(a, b) {
|
|
10540
|
+
var a0 = a[0], a1 = a[1], a2 = a[2];
|
|
10541
|
+
var b0 = b[0], b1 = b[1], b2 = b[2];
|
|
10542
|
+
if (a0 === b0 && a1 === b1 && a2 === b2)
|
|
10543
|
+
return true;
|
|
10544
|
+
return (Math.abs(a0 - b0) <= EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) &&
|
|
10545
|
+
Math.abs(a1 - b1) <= EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) &&
|
|
10546
|
+
Math.abs(a2 - b2) <= EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)));
|
|
10547
|
+
}
|
|
10480
10548
|
/**
|
|
10481
10549
|
* update transform in scene graph
|
|
10482
10550
|
*
|
|
@@ -10588,7 +10656,7 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10588
10656
|
translation = glMatrix.vec3.fromValues(translation, y, z);
|
|
10589
10657
|
}
|
|
10590
10658
|
var transform = element.transformable;
|
|
10591
|
-
if (
|
|
10659
|
+
if (equals(translation, glMatrix.vec3.create())) {
|
|
10592
10660
|
return;
|
|
10593
10661
|
}
|
|
10594
10662
|
glMatrix.vec3.transformQuat(translation, translation, transform.localRotation);
|
|
@@ -10613,7 +10681,7 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10613
10681
|
tmpPosition[0] = position[0];
|
|
10614
10682
|
tmpPosition[1] = position[1];
|
|
10615
10683
|
tmpPosition[2] = position[2] || 0;
|
|
10616
|
-
if (
|
|
10684
|
+
if (equals(_this.getPosition(element), tmpPosition)) {
|
|
10617
10685
|
return;
|
|
10618
10686
|
}
|
|
10619
10687
|
glMatrix.vec3.copy(transform.position, tmpPosition);
|
|
@@ -10643,7 +10711,7 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10643
10711
|
tmpPosition[0] = position[0];
|
|
10644
10712
|
tmpPosition[1] = position[1];
|
|
10645
10713
|
tmpPosition[2] = position[2] || 0;
|
|
10646
|
-
if (
|
|
10714
|
+
if (equals(transform.localPosition, tmpPosition)) {
|
|
10647
10715
|
return;
|
|
10648
10716
|
}
|
|
10649
10717
|
glMatrix.vec3.copy(transform.localPosition, tmpPosition);
|
|
@@ -10675,7 +10743,7 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10675
10743
|
if (typeof translation === 'number') {
|
|
10676
10744
|
translation = glMatrix.vec3.set(tmpVec3, translation, y, z);
|
|
10677
10745
|
}
|
|
10678
|
-
if (
|
|
10746
|
+
if (equals(translation, zeroVec3)) {
|
|
10679
10747
|
return;
|
|
10680
10748
|
}
|
|
10681
10749
|
glMatrix.vec3.add(tr, _this.getPosition(element), translation);
|
|
@@ -10706,6 +10774,7 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10706
10774
|
}
|
|
10707
10775
|
};
|
|
10708
10776
|
};
|
|
10777
|
+
this.eventEntitySet = new Set();
|
|
10709
10778
|
this.displayObjectDependencyMap = new WeakMap();
|
|
10710
10779
|
this.calcLocalTransform = (function () {
|
|
10711
10780
|
var tmpMat = glMatrix.mat4.create();
|
|
@@ -10873,7 +10942,7 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10873
10942
|
if (dirtify === void 0) { dirtify = true; }
|
|
10874
10943
|
var transform = element.transformable;
|
|
10875
10944
|
var updatedScaling = glMatrix.vec3.fromValues(scaling[0], scaling[1], scaling[2] || transform.localScale[2]);
|
|
10876
|
-
if (
|
|
10945
|
+
if (equals(updatedScaling, transform.localScale)) {
|
|
10877
10946
|
return;
|
|
10878
10947
|
}
|
|
10879
10948
|
glMatrix.vec3.copy(transform.localScale, updatedScaling);
|
|
@@ -10915,35 +10984,47 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10915
10984
|
this.dirtifyWorldInternal(element, transform);
|
|
10916
10985
|
this.dirtifyToRoot(element, true);
|
|
10917
10986
|
};
|
|
10918
|
-
DefaultSceneGraphService.prototype.
|
|
10987
|
+
DefaultSceneGraphService.prototype.triggerEvent = function (element, detail) {
|
|
10988
|
+
if (element.isConnected && !this.eventEntitySet.has(element.entity)) {
|
|
10989
|
+
this.boundsChangedEvent.detail = detail;
|
|
10990
|
+
this.boundsChangedEvent.target = element;
|
|
10991
|
+
if (element.isMutationObserved) {
|
|
10992
|
+
element.dispatchEvent(this.boundsChangedEvent);
|
|
10993
|
+
}
|
|
10994
|
+
else {
|
|
10995
|
+
element.ownerDocument.defaultView.dispatchEvent(this.boundsChangedEvent, true);
|
|
10996
|
+
}
|
|
10997
|
+
this.eventEntitySet.add(element.entity);
|
|
10998
|
+
}
|
|
10999
|
+
};
|
|
11000
|
+
DefaultSceneGraphService.prototype.triggerPendingEvents = function (root) {
|
|
10919
11001
|
var _this = this;
|
|
10920
|
-
|
|
10921
|
-
|
|
10922
|
-
|
|
10923
|
-
|
|
10924
|
-
|
|
10925
|
-
|
|
10926
|
-
|
|
11002
|
+
if (root) {
|
|
11003
|
+
root.forEach(function (e) {
|
|
11004
|
+
_this.triggerEvent(e, { affectChildren: true });
|
|
11005
|
+
});
|
|
11006
|
+
}
|
|
11007
|
+
else {
|
|
11008
|
+
var events = this.pendingEvents;
|
|
11009
|
+
var length_1 = events.length;
|
|
11010
|
+
var _loop_1 = function (i) {
|
|
11011
|
+
var _a = tslib.__read(events[i], 2), element = _a[0], detail = _a[1];
|
|
11012
|
+
if (detail.affectChildren) {
|
|
11013
|
+
element.forEach(function (e) {
|
|
11014
|
+
_this.triggerEvent(e, detail);
|
|
11015
|
+
});
|
|
10927
11016
|
}
|
|
10928
11017
|
else {
|
|
10929
|
-
|
|
11018
|
+
this_1.triggerEvent(element, detail);
|
|
10930
11019
|
}
|
|
10931
|
-
|
|
10932
|
-
|
|
10933
|
-
|
|
10934
|
-
|
|
10935
|
-
var _b = tslib.__read(_a, 2), element = _b[0], detail = _b[1];
|
|
10936
|
-
if (detail.affectChildren) {
|
|
10937
|
-
element.forEach(function (e) {
|
|
10938
|
-
trigger(e, detail);
|
|
10939
|
-
});
|
|
10940
|
-
}
|
|
10941
|
-
else {
|
|
10942
|
-
trigger(element, detail);
|
|
11020
|
+
};
|
|
11021
|
+
var this_1 = this;
|
|
11022
|
+
for (var i = 0; i < length_1; i++) {
|
|
11023
|
+
_loop_1(i);
|
|
10943
11024
|
}
|
|
10944
|
-
}
|
|
11025
|
+
}
|
|
11026
|
+
this.eventEntitySet.clear();
|
|
10945
11027
|
this.clearPendingEvents();
|
|
10946
|
-
set.clear();
|
|
10947
11028
|
};
|
|
10948
11029
|
DefaultSceneGraphService.prototype.clearPendingEvents = function () {
|
|
10949
11030
|
this.pendingEvents = [];
|
|
@@ -11051,9 +11132,9 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
11051
11132
|
return transform.localTransform;
|
|
11052
11133
|
};
|
|
11053
11134
|
DefaultSceneGraphService.prototype.setLocalTransform = function (element, transform) {
|
|
11054
|
-
var t = glMatrix.mat4.getTranslation(
|
|
11055
|
-
var r = glMatrix.mat4.getRotation(
|
|
11056
|
-
var s = glMatrix.mat4.getScaling(
|
|
11135
|
+
var t = glMatrix.mat4.getTranslation([0, 0, 0], transform);
|
|
11136
|
+
var r = glMatrix.mat4.getRotation([0, 0, 0, 1], transform);
|
|
11137
|
+
var s = glMatrix.mat4.getScaling([0, 0, 0], transform);
|
|
11057
11138
|
this.setLocalScale(element, s, false);
|
|
11058
11139
|
this.setLocalPosition(element, t, false);
|
|
11059
11140
|
this.setLocalRotation(element, r, undefined, undefined, undefined, false);
|
|
@@ -11676,7 +11757,7 @@ var geometryUpdaterFactory = (function () {
|
|
|
11676
11757
|
_a[exports.Shape.POLYLINE] = polylineUpdater,
|
|
11677
11758
|
_a[exports.Shape.POLYGON] = polylineUpdater,
|
|
11678
11759
|
_a[exports.Shape.PATH] = new PathUpdater(),
|
|
11679
|
-
_a[exports.Shape.HTML] =
|
|
11760
|
+
_a[exports.Shape.HTML] = new HTMLUpdater(),
|
|
11680
11761
|
_a[exports.Shape.MESH] = null,
|
|
11681
11762
|
_a;
|
|
11682
11763
|
})();
|
|
@@ -13189,35 +13270,36 @@ var HTML = /** @class */ (function (_super) {
|
|
|
13189
13270
|
/**
|
|
13190
13271
|
* override with $el.getBoundingClientRect
|
|
13191
13272
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/getBoundingClientRect
|
|
13192
|
-
|
|
13193
|
-
|
|
13194
|
-
|
|
13195
|
-
|
|
13196
|
-
|
|
13197
|
-
|
|
13198
|
-
|
|
13199
|
-
|
|
13200
|
-
|
|
13201
|
-
|
|
13202
|
-
|
|
13203
|
-
return new Rectangle(x, y, width, height);
|
|
13204
|
-
}
|
|
13205
|
-
};
|
|
13273
|
+
*
|
|
13274
|
+
* ! The calculation logic of the html element should be consistent with that of the canvas element
|
|
13275
|
+
*/
|
|
13276
|
+
// getBoundingClientRect(): Rectangle {
|
|
13277
|
+
// if (this.parsedStyle.$el) {
|
|
13278
|
+
// return this.parsedStyle.$el.getBoundingClientRect();
|
|
13279
|
+
// } else {
|
|
13280
|
+
// const { x, y, width, height } = this.parsedStyle;
|
|
13281
|
+
// return new Rectangle(x, y, width, height);
|
|
13282
|
+
// }
|
|
13283
|
+
// }
|
|
13206
13284
|
HTML.prototype.getClientRects = function () {
|
|
13207
13285
|
return [this.getBoundingClientRect()];
|
|
13208
13286
|
};
|
|
13209
|
-
|
|
13210
|
-
|
|
13211
|
-
|
|
13212
|
-
|
|
13213
|
-
|
|
13214
|
-
|
|
13215
|
-
|
|
13216
|
-
|
|
13217
|
-
|
|
13218
|
-
|
|
13219
|
-
|
|
13220
|
-
|
|
13287
|
+
// getBounds() {
|
|
13288
|
+
// const clientRect = this.getBoundingClientRect();
|
|
13289
|
+
// // calc context's offset
|
|
13290
|
+
// // @ts-ignore
|
|
13291
|
+
// const canvasRect = this.ownerDocument?.defaultView
|
|
13292
|
+
// ?.getContextService()
|
|
13293
|
+
// .getBoundingClientRect();
|
|
13294
|
+
// const aabb = new AABB();
|
|
13295
|
+
// const minX = clientRect.left - (canvasRect?.left || 0);
|
|
13296
|
+
// const minY = clientRect.top - (canvasRect?.top || 0);
|
|
13297
|
+
// aabb.setMinMax(
|
|
13298
|
+
// [minX, minY, 0],
|
|
13299
|
+
// [minX + clientRect.width, minY + clientRect.height, 0],
|
|
13300
|
+
// );
|
|
13301
|
+
// return aabb;
|
|
13302
|
+
// }
|
|
13221
13303
|
HTML.prototype.getLocalBounds = function () {
|
|
13222
13304
|
if (this.parentNode) {
|
|
13223
13305
|
var parentInvert = glMatrix.mat4.invert(glMatrix.mat4.create(), this.parentNode.getWorldTransform());
|
|
@@ -14804,7 +14886,6 @@ var PrepareRendererPlugin = /** @class */ (function () {
|
|
|
14804
14886
|
* sync to RBush later
|
|
14805
14887
|
*/
|
|
14806
14888
|
this.toSync = new Set();
|
|
14807
|
-
this.isFirstTimeRendering = true;
|
|
14808
14889
|
this.syncing = false;
|
|
14809
14890
|
this.isFirstTimeRenderingFinished = false;
|
|
14810
14891
|
}
|
|
@@ -14874,8 +14955,9 @@ var PrepareRendererPlugin = /** @class */ (function () {
|
|
|
14874
14955
|
});
|
|
14875
14956
|
var ric = (_a = runtime.globalThis.requestIdleCallback) !== null && _a !== void 0 ? _a : raf.bind(runtime.globalThis);
|
|
14876
14957
|
renderingService.hooks.endFrame.tap(PrepareRendererPlugin.tag, function () {
|
|
14877
|
-
|
|
14878
|
-
|
|
14958
|
+
var frame = context.renderingService.frame;
|
|
14959
|
+
if (frame === 1) ;
|
|
14960
|
+
else if (frame === 2) {
|
|
14879
14961
|
_this.syncing = true;
|
|
14880
14962
|
ric(function () {
|
|
14881
14963
|
_this.syncRTree(true);
|
|
@@ -14896,13 +14978,12 @@ var PrepareRendererPlugin = /** @class */ (function () {
|
|
|
14896
14978
|
this.syncing = true;
|
|
14897
14979
|
// bounds changed, need re-inserting its children
|
|
14898
14980
|
var bulk = [];
|
|
14899
|
-
|
|
14900
|
-
|
|
14901
|
-
|
|
14902
|
-
.forEach(function (node) {
|
|
14981
|
+
this.toSync.forEach(function (node) {
|
|
14982
|
+
if (node.isConnected)
|
|
14983
|
+
return;
|
|
14903
14984
|
var rBushNode = node.rBushNode;
|
|
14904
14985
|
// clear dirty node
|
|
14905
|
-
if (rBushNode
|
|
14986
|
+
if (rBushNode === null || rBushNode === void 0 ? void 0 : rBushNode.aabb) {
|
|
14906
14987
|
_this.rBush.remove(rBushNode.aabb);
|
|
14907
14988
|
}
|
|
14908
14989
|
var renderBounds = node.getRenderBounds();
|
|
@@ -15309,13 +15390,13 @@ var Canvas = /** @class */ (function (_super) {
|
|
|
15309
15390
|
});
|
|
15310
15391
|
}
|
|
15311
15392
|
};
|
|
15312
|
-
Canvas.prototype.initRenderingService = function (renderer,
|
|
15393
|
+
Canvas.prototype.initRenderingService = function (renderer, firstContentfulPaint, async) {
|
|
15313
15394
|
var _this = this;
|
|
15314
|
-
if (
|
|
15395
|
+
if (firstContentfulPaint === void 0) { firstContentfulPaint = false; }
|
|
15315
15396
|
if (async === void 0) { async = false; }
|
|
15316
15397
|
this.context.renderingService.init(function () {
|
|
15317
15398
|
_this.inited = true;
|
|
15318
|
-
if (
|
|
15399
|
+
if (firstContentfulPaint) {
|
|
15319
15400
|
if (async) {
|
|
15320
15401
|
_this.requestAnimationFrame(function () {
|
|
15321
15402
|
_this.dispatchEvent(new CustomEvent(exports.CanvasEvent.READY));
|
|
@@ -15331,7 +15412,7 @@ var Canvas = /** @class */ (function (_super) {
|
|
|
15331
15412
|
if (_this.readyPromise) {
|
|
15332
15413
|
_this.resolveReadyPromise();
|
|
15333
15414
|
}
|
|
15334
|
-
if (!
|
|
15415
|
+
if (!firstContentfulPaint) {
|
|
15335
15416
|
_this.getRoot().forEach(function (node) {
|
|
15336
15417
|
var renderable = node.renderable;
|
|
15337
15418
|
if (renderable) {
|
|
@@ -15499,6 +15580,7 @@ exports.Frustum = Frustum;
|
|
|
15499
15580
|
exports.Group = Group;
|
|
15500
15581
|
exports.GroupUpdater = GroupUpdater;
|
|
15501
15582
|
exports.HTML = HTML;
|
|
15583
|
+
exports.HTMLUpdater = HTMLUpdater;
|
|
15502
15584
|
exports.Image = Image;
|
|
15503
15585
|
exports.Line = Line;
|
|
15504
15586
|
exports.LineUpdater = LineUpdater;
|