@antv/g-lite 2.0.9 → 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/index.d.ts +1 -0
- package/dist/index.esm.js +176 -111
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +176 -111
- 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/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
|
}
|
|
@@ -10093,6 +10124,12 @@ var RenderingService = /** @class */ (function () {
|
|
|
10093
10124
|
*/
|
|
10094
10125
|
rendered: 0,
|
|
10095
10126
|
};
|
|
10127
|
+
/**
|
|
10128
|
+
* frame counter
|
|
10129
|
+
* - 1 - init root container
|
|
10130
|
+
* - 2 - user first frame
|
|
10131
|
+
*/
|
|
10132
|
+
this.frame = 0;
|
|
10096
10133
|
this.zIndexCounter = 0;
|
|
10097
10134
|
this.hooks = {
|
|
10098
10135
|
/**
|
|
@@ -10185,9 +10222,12 @@ var RenderingService = /** @class */ (function () {
|
|
|
10185
10222
|
this.stats.total = 0;
|
|
10186
10223
|
this.stats.rendered = 0;
|
|
10187
10224
|
this.zIndexCounter = 0;
|
|
10225
|
+
this.frame++;
|
|
10188
10226
|
var renderingContext = this.context.renderingContext;
|
|
10189
10227
|
this.globalRuntime.sceneGraphService.syncHierarchy(renderingContext.root);
|
|
10190
|
-
this.
|
|
10228
|
+
if (this.frame > 2) {
|
|
10229
|
+
this.globalRuntime.sceneGraphService.triggerPendingEvents(this.frame === 3 ? renderingContext.root : undefined);
|
|
10230
|
+
}
|
|
10191
10231
|
if (renderingContext.renderReasons.size && this.inited) {
|
|
10192
10232
|
// @ts-ignore
|
|
10193
10233
|
renderingContext.dirtyRectangleRenderingDisabled =
|
|
@@ -10492,6 +10532,19 @@ function markRenderableDirty(e) {
|
|
|
10492
10532
|
}
|
|
10493
10533
|
}
|
|
10494
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
|
+
}
|
|
10495
10548
|
/**
|
|
10496
10549
|
* update transform in scene graph
|
|
10497
10550
|
*
|
|
@@ -10603,7 +10656,7 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10603
10656
|
translation = glMatrix.vec3.fromValues(translation, y, z);
|
|
10604
10657
|
}
|
|
10605
10658
|
var transform = element.transformable;
|
|
10606
|
-
if (
|
|
10659
|
+
if (equals(translation, glMatrix.vec3.create())) {
|
|
10607
10660
|
return;
|
|
10608
10661
|
}
|
|
10609
10662
|
glMatrix.vec3.transformQuat(translation, translation, transform.localRotation);
|
|
@@ -10628,7 +10681,7 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10628
10681
|
tmpPosition[0] = position[0];
|
|
10629
10682
|
tmpPosition[1] = position[1];
|
|
10630
10683
|
tmpPosition[2] = position[2] || 0;
|
|
10631
|
-
if (
|
|
10684
|
+
if (equals(_this.getPosition(element), tmpPosition)) {
|
|
10632
10685
|
return;
|
|
10633
10686
|
}
|
|
10634
10687
|
glMatrix.vec3.copy(transform.position, tmpPosition);
|
|
@@ -10658,7 +10711,7 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10658
10711
|
tmpPosition[0] = position[0];
|
|
10659
10712
|
tmpPosition[1] = position[1];
|
|
10660
10713
|
tmpPosition[2] = position[2] || 0;
|
|
10661
|
-
if (
|
|
10714
|
+
if (equals(transform.localPosition, tmpPosition)) {
|
|
10662
10715
|
return;
|
|
10663
10716
|
}
|
|
10664
10717
|
glMatrix.vec3.copy(transform.localPosition, tmpPosition);
|
|
@@ -10690,7 +10743,7 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10690
10743
|
if (typeof translation === 'number') {
|
|
10691
10744
|
translation = glMatrix.vec3.set(tmpVec3, translation, y, z);
|
|
10692
10745
|
}
|
|
10693
|
-
if (
|
|
10746
|
+
if (equals(translation, zeroVec3)) {
|
|
10694
10747
|
return;
|
|
10695
10748
|
}
|
|
10696
10749
|
glMatrix.vec3.add(tr, _this.getPosition(element), translation);
|
|
@@ -10721,6 +10774,7 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10721
10774
|
}
|
|
10722
10775
|
};
|
|
10723
10776
|
};
|
|
10777
|
+
this.eventEntitySet = new Set();
|
|
10724
10778
|
this.displayObjectDependencyMap = new WeakMap();
|
|
10725
10779
|
this.calcLocalTransform = (function () {
|
|
10726
10780
|
var tmpMat = glMatrix.mat4.create();
|
|
@@ -10888,7 +10942,7 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10888
10942
|
if (dirtify === void 0) { dirtify = true; }
|
|
10889
10943
|
var transform = element.transformable;
|
|
10890
10944
|
var updatedScaling = glMatrix.vec3.fromValues(scaling[0], scaling[1], scaling[2] || transform.localScale[2]);
|
|
10891
|
-
if (
|
|
10945
|
+
if (equals(updatedScaling, transform.localScale)) {
|
|
10892
10946
|
return;
|
|
10893
10947
|
}
|
|
10894
10948
|
glMatrix.vec3.copy(transform.localScale, updatedScaling);
|
|
@@ -10930,35 +10984,47 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10930
10984
|
this.dirtifyWorldInternal(element, transform);
|
|
10931
10985
|
this.dirtifyToRoot(element, true);
|
|
10932
10986
|
};
|
|
10933
|
-
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) {
|
|
10934
11001
|
var _this = this;
|
|
10935
|
-
|
|
10936
|
-
|
|
10937
|
-
|
|
10938
|
-
|
|
10939
|
-
|
|
10940
|
-
|
|
10941
|
-
|
|
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
|
+
});
|
|
10942
11016
|
}
|
|
10943
11017
|
else {
|
|
10944
|
-
|
|
11018
|
+
this_1.triggerEvent(element, detail);
|
|
10945
11019
|
}
|
|
10946
|
-
|
|
10947
|
-
|
|
10948
|
-
|
|
10949
|
-
|
|
10950
|
-
var _b = tslib.__read(_a, 2), element = _b[0], detail = _b[1];
|
|
10951
|
-
if (detail.affectChildren) {
|
|
10952
|
-
element.forEach(function (e) {
|
|
10953
|
-
trigger(e, detail);
|
|
10954
|
-
});
|
|
10955
|
-
}
|
|
10956
|
-
else {
|
|
10957
|
-
trigger(element, detail);
|
|
11020
|
+
};
|
|
11021
|
+
var this_1 = this;
|
|
11022
|
+
for (var i = 0; i < length_1; i++) {
|
|
11023
|
+
_loop_1(i);
|
|
10958
11024
|
}
|
|
10959
|
-
}
|
|
11025
|
+
}
|
|
11026
|
+
this.eventEntitySet.clear();
|
|
10960
11027
|
this.clearPendingEvents();
|
|
10961
|
-
set.clear();
|
|
10962
11028
|
};
|
|
10963
11029
|
DefaultSceneGraphService.prototype.clearPendingEvents = function () {
|
|
10964
11030
|
this.pendingEvents = [];
|
|
@@ -11066,9 +11132,9 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
11066
11132
|
return transform.localTransform;
|
|
11067
11133
|
};
|
|
11068
11134
|
DefaultSceneGraphService.prototype.setLocalTransform = function (element, transform) {
|
|
11069
|
-
var t = glMatrix.mat4.getTranslation(
|
|
11070
|
-
var r = glMatrix.mat4.getRotation(
|
|
11071
|
-
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);
|
|
11072
11138
|
this.setLocalScale(element, s, false);
|
|
11073
11139
|
this.setLocalPosition(element, t, false);
|
|
11074
11140
|
this.setLocalRotation(element, r, undefined, undefined, undefined, false);
|
|
@@ -14820,7 +14886,6 @@ var PrepareRendererPlugin = /** @class */ (function () {
|
|
|
14820
14886
|
* sync to RBush later
|
|
14821
14887
|
*/
|
|
14822
14888
|
this.toSync = new Set();
|
|
14823
|
-
this.isFirstTimeRendering = true;
|
|
14824
14889
|
this.syncing = false;
|
|
14825
14890
|
this.isFirstTimeRenderingFinished = false;
|
|
14826
14891
|
}
|
|
@@ -14890,8 +14955,9 @@ var PrepareRendererPlugin = /** @class */ (function () {
|
|
|
14890
14955
|
});
|
|
14891
14956
|
var ric = (_a = runtime.globalThis.requestIdleCallback) !== null && _a !== void 0 ? _a : raf.bind(runtime.globalThis);
|
|
14892
14957
|
renderingService.hooks.endFrame.tap(PrepareRendererPlugin.tag, function () {
|
|
14893
|
-
|
|
14894
|
-
|
|
14958
|
+
var frame = context.renderingService.frame;
|
|
14959
|
+
if (frame === 1) ;
|
|
14960
|
+
else if (frame === 2) {
|
|
14895
14961
|
_this.syncing = true;
|
|
14896
14962
|
ric(function () {
|
|
14897
14963
|
_this.syncRTree(true);
|
|
@@ -14912,13 +14978,12 @@ var PrepareRendererPlugin = /** @class */ (function () {
|
|
|
14912
14978
|
this.syncing = true;
|
|
14913
14979
|
// bounds changed, need re-inserting its children
|
|
14914
14980
|
var bulk = [];
|
|
14915
|
-
|
|
14916
|
-
|
|
14917
|
-
|
|
14918
|
-
.forEach(function (node) {
|
|
14981
|
+
this.toSync.forEach(function (node) {
|
|
14982
|
+
if (node.isConnected)
|
|
14983
|
+
return;
|
|
14919
14984
|
var rBushNode = node.rBushNode;
|
|
14920
14985
|
// clear dirty node
|
|
14921
|
-
if (rBushNode
|
|
14986
|
+
if (rBushNode === null || rBushNode === void 0 ? void 0 : rBushNode.aabb) {
|
|
14922
14987
|
_this.rBush.remove(rBushNode.aabb);
|
|
14923
14988
|
}
|
|
14924
14989
|
var renderBounds = node.getRenderBounds();
|
|
@@ -15325,13 +15390,13 @@ var Canvas = /** @class */ (function (_super) {
|
|
|
15325
15390
|
});
|
|
15326
15391
|
}
|
|
15327
15392
|
};
|
|
15328
|
-
Canvas.prototype.initRenderingService = function (renderer,
|
|
15393
|
+
Canvas.prototype.initRenderingService = function (renderer, firstContentfulPaint, async) {
|
|
15329
15394
|
var _this = this;
|
|
15330
|
-
if (
|
|
15395
|
+
if (firstContentfulPaint === void 0) { firstContentfulPaint = false; }
|
|
15331
15396
|
if (async === void 0) { async = false; }
|
|
15332
15397
|
this.context.renderingService.init(function () {
|
|
15333
15398
|
_this.inited = true;
|
|
15334
|
-
if (
|
|
15399
|
+
if (firstContentfulPaint) {
|
|
15335
15400
|
if (async) {
|
|
15336
15401
|
_this.requestAnimationFrame(function () {
|
|
15337
15402
|
_this.dispatchEvent(new CustomEvent(exports.CanvasEvent.READY));
|
|
@@ -15347,7 +15412,7 @@ var Canvas = /** @class */ (function (_super) {
|
|
|
15347
15412
|
if (_this.readyPromise) {
|
|
15348
15413
|
_this.resolveReadyPromise();
|
|
15349
15414
|
}
|
|
15350
|
-
if (!
|
|
15415
|
+
if (!firstContentfulPaint) {
|
|
15351
15416
|
_this.getRoot().forEach(function (node) {
|
|
15352
15417
|
var renderable = node.renderable;
|
|
15353
15418
|
if (renderable) {
|