@antv/g-lite 2.0.10-alpha.0 → 2.0.10

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.
@@ -24,4 +24,5 @@ export declare class CSSUnitValue extends CSSStyleValue {
24
24
  buildCSSText(n: Nested, p: ParenLess, result: string): string;
25
25
  }
26
26
  export declare const Opx: CSSUnitValue;
27
+ export declare const Lpx: CSSUnitValue;
27
28
  export declare const Odeg: CSSUnitValue;
@@ -1,6 +1,5 @@
1
1
  import type { DisplayObject } from '../../display-objects';
2
2
  import { CSSUnitValue } from '../cssom';
3
- import type { TransformArray } from '../../types';
4
3
  export interface ParsedTransform {
5
4
  t: string;
6
5
  d: CSSUnitValue[];
@@ -10,8 +9,8 @@ export interface ParsedTransform {
10
9
  * scale(1) scale(1, 2)
11
10
  * scaleX(1)
12
11
  */
13
- export declare function parseTransform(transform: string | TransformArray): ParsedTransform[];
14
- export declare function parseTransformUnmemoize(transform: string | TransformArray): ParsedTransform[];
12
+ export declare function parseTransform(string: string): ParsedTransform[];
13
+ export declare function parseTransformUnmemoize(string: string): ParsedTransform[];
15
14
  export declare function convertItemToMatrix(item: ParsedTransform): number[];
16
15
  export declare const composeMatrix: (translate: any, scale: any, skew: any, quat: any, perspective: any) => number[];
17
16
  export declare function mergeTransforms(left: ParsedTransform[], right: ParsedTransform[], target: DisplayObject | null): [number[][], number[][], (d: number[][]) => string];
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import './preset';
2
1
  import RBush from 'rbush/rbush.js';
3
2
  export * from './AbstractRenderer';
4
3
  export * from './Canvas';
package/dist/index.esm.js CHANGED
@@ -1,12 +1,10 @@
1
- import { glMatrix, mat4, vec4, vec3, mat3, quat as quat$1, vec2 } from 'gl-matrix';
2
1
  import { __assign, __read, __extends, __spreadArray, __awaiter, __generator, __values, __rest } from 'tslib';
3
2
  import EventEmitter from 'eventemitter3';
3
+ import { mat4, vec4, vec3, mat3, quat as quat$1, vec2 } from 'gl-matrix';
4
4
  import { isNumber, distanceSquareRoot, isString, isNil, clamp, getTotalLength, min, max, isNumberEqual, mod, normalizePath, path2Curve, equalizeSegments, getDrawDirection, reverseCurve, clonePath, getRotatedCurve, isUndefined, isArray, isBoolean, isObject, getPointAtLength } from '@antv/util';
5
5
  import * as d3 from 'd3-color';
6
6
  import { polylineLength, arcBox, cubicBox, quadBox, linePointAt, lineLength } from '@antv/g-math';
7
7
 
8
- glMatrix.setMatrixArrayType(Array);
9
-
10
8
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
11
9
 
12
10
  var rbush = {exports: {}};
@@ -643,7 +641,7 @@ var AbstractRenderer = /** @class */ (function () {
643
641
  /**
644
642
  * enable dirty rectangle rendering by default
645
643
  */
646
- enableDirtyRectangleRendering: true, enableDirtyRectangleRenderingDebug: false, enableSizeAttenuation: true, imageSmoothingEnabled: true, imageSmoothingQuality: 'high' }, config);
644
+ enableDirtyRectangleRendering: true, enableDirtyRectangleRenderingDebug: false, enableSizeAttenuation: true }, config);
647
645
  }
648
646
  AbstractRenderer.prototype.registerPlugin = function (plugin) {
649
647
  var index = this.plugins.findIndex(function (p) { return p === plugin; });
@@ -3108,25 +3106,25 @@ var CSSUnitValue = /** @class */ (function (_super) {
3108
3106
  case UnitType.kSeconds:
3109
3107
  // case UnitType.kHertz:
3110
3108
  // case UnitType.kKilohertz:
3111
- // 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:
3112
- case UnitType.kTurns: {
3113
- var kMinInteger = -999999;
3114
- var kMaxInteger = 999999;
3115
- var value = this.value;
3116
- var unit = unitTypeToString(this.unit);
3117
- if (value < kMinInteger || value > kMaxInteger) {
3118
- var unit_1 = unitTypeToString(this.unit);
3119
- if (!Number.isFinite(value) || Number.isNaN(value)) {
3120
- text = formatInfinityOrNaN(value, unit_1);
3109
+ case UnitType.kTurns: // 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:
3110
+ {
3111
+ var kMinInteger = -999999;
3112
+ var kMaxInteger = 999999;
3113
+ var value = this.value;
3114
+ var unit = unitTypeToString(this.unit);
3115
+ if (value < kMinInteger || value > kMaxInteger) {
3116
+ var unit_1 = unitTypeToString(this.unit);
3117
+ if (!Number.isFinite(value) || Number.isNaN(value)) {
3118
+ text = formatInfinityOrNaN(value, unit_1);
3119
+ }
3120
+ else {
3121
+ text = value + (unit_1 || '');
3122
+ }
3121
3123
  }
3122
3124
  else {
3123
- text = value + (unit_1 || '');
3125
+ text = "".concat(value).concat(unit);
3124
3126
  }
3125
3127
  }
3126
- else {
3127
- text = "".concat(value).concat(unit);
3128
- }
3129
- }
3130
3128
  }
3131
3129
  result += text;
3132
3130
  return result;
@@ -3134,6 +3132,7 @@ var CSSUnitValue = /** @class */ (function (_super) {
3134
3132
  return CSSUnitValue;
3135
3133
  }(CSSStyleValue));
3136
3134
  var Opx = new CSSUnitValue(0, 'px');
3135
+ new CSSUnitValue(1, 'px');
3137
3136
  var Odeg = new CSSUnitValue(0, 'deg');
3138
3137
 
3139
3138
  /**
@@ -5163,7 +5162,6 @@ function mergePoints(left, right) {
5163
5162
  }
5164
5163
 
5165
5164
  var _ = null;
5166
- var TRANSFORM_REGEXP = /\s*(\w+)\(([^)]*)\)/g;
5167
5165
  function cast(pattern) {
5168
5166
  return function (contents) {
5169
5167
  var i = 0;
@@ -5182,75 +5180,48 @@ var transformFunctions = {
5182
5180
  matrix: ['NNNNNN', [_, _, 0, 0, _, _, 0, 0, 0, 0, 1, 0, _, _, 0, 1], id],
5183
5181
  matrix3d: ['NNNNNNNNNNNNNNNN', id],
5184
5182
  rotate: ['A'],
5185
- rotateX: ['A'],
5186
- rotateY: ['A'],
5187
- rotateZ: ['A'],
5183
+ rotatex: ['A'],
5184
+ rotatey: ['A'],
5185
+ rotatez: ['A'],
5188
5186
  rotate3d: ['NNNA'],
5189
5187
  perspective: ['L'],
5190
5188
  scale: ['Nn', cast([_, _, new CSSUnitValue(1)]), id],
5191
- scaleX: [
5189
+ scalex: [
5192
5190
  'N',
5193
5191
  cast([_, new CSSUnitValue(1), new CSSUnitValue(1)]),
5194
5192
  cast([_, new CSSUnitValue(1)]),
5195
5193
  ],
5196
- scaleY: [
5194
+ scaley: [
5197
5195
  'N',
5198
5196
  cast([new CSSUnitValue(1), _, new CSSUnitValue(1)]),
5199
5197
  cast([new CSSUnitValue(1), _]),
5200
5198
  ],
5201
- scaleZ: ['N', cast([new CSSUnitValue(1), new CSSUnitValue(1), _])],
5199
+ scalez: ['N', cast([new CSSUnitValue(1), new CSSUnitValue(1), _])],
5202
5200
  scale3d: ['NNN', id],
5203
5201
  skew: ['Aa', null, id],
5204
- skewX: ['A', null, cast([_, Odeg])],
5205
- skewY: ['A', null, cast([Odeg, _])],
5202
+ skewx: ['A', null, cast([_, Odeg])],
5203
+ skewy: ['A', null, cast([Odeg, _])],
5206
5204
  translate: ['Tt', cast([_, _, Opx]), id],
5207
- translateX: ['T', cast([_, Opx, Opx]), cast([_, Opx])],
5208
- translateY: ['T', cast([Opx, _, Opx]), cast([Opx, _])],
5209
- translateZ: ['L', cast([Opx, Opx, _])],
5205
+ translatex: ['T', cast([_, Opx, Opx]), cast([_, Opx])],
5206
+ translatey: ['T', cast([Opx, _, Opx]), cast([Opx, _])],
5207
+ translatez: ['L', cast([Opx, Opx, _])],
5210
5208
  translate3d: ['TTL', id],
5211
5209
  };
5212
- function parseArrayTransform(transform) {
5213
- var result = [];
5214
- var length = transform.length;
5215
- for (var i = 0; i < length; i++) {
5216
- var item = transform[i];
5217
- var name_1 = item[0];
5218
- var args = item.slice(1);
5219
- // infer default value
5220
- if (name_1 === 'translate' || name_1 === 'skew') {
5221
- if (args.length === 1)
5222
- args.push(0);
5223
- }
5224
- else if (name_1 === 'scale') {
5225
- if (args.length === 1)
5226
- args.push(args[0]);
5227
- }
5228
- var functionData = transformFunctions[name_1];
5229
- if (!functionData)
5230
- return [];
5231
- var parsedArgs = args.map(function (value) { return getOrCreateUnitValue(value); });
5232
- result.push({ t: name_1, d: parsedArgs });
5233
- }
5234
- return result;
5235
- }
5236
5210
  /**
5237
5211
  * none
5238
5212
  * scale(1) scale(1, 2)
5239
5213
  * scaleX(1)
5240
5214
  */
5241
- function parseTransform(transform) {
5242
- if (Array.isArray(transform)) {
5243
- return parseArrayTransform(transform);
5244
- }
5245
- transform = (transform || 'none').trim();
5246
- if (transform === 'none') {
5215
+ function parseTransform(string) {
5216
+ string = (string || 'none').toLowerCase().trim();
5217
+ if (string === 'none') {
5247
5218
  return [];
5248
5219
  }
5220
+ var transformRegExp = /\s*(\w+)\(([^)]*)\)/g;
5249
5221
  var result = [];
5250
5222
  var match;
5251
5223
  var prevLastIndex = 0;
5252
- TRANSFORM_REGEXP.lastIndex = 0;
5253
- while ((match = TRANSFORM_REGEXP.exec(transform))) {
5224
+ while ((match = transformRegExp.exec(string))) {
5254
5225
  if (match.index !== prevLastIndex) {
5255
5226
  return [];
5256
5227
  }
@@ -5297,24 +5268,22 @@ function parseTransform(transform) {
5297
5268
  parsedArgs.push(parsedArg);
5298
5269
  }
5299
5270
  result.push({ t: functionName, d: parsedArgs }); // { t: scale, d: [1, 2] }
5300
- if (TRANSFORM_REGEXP.lastIndex === transform.length) {
5271
+ if (transformRegExp.lastIndex === string.length) {
5301
5272
  return result;
5302
5273
  }
5303
5274
  }
5304
5275
  return [];
5305
5276
  }
5306
- function parseTransformUnmemoize(transform) {
5307
- if (Array.isArray(transform)) {
5308
- return parseArrayTransform(transform);
5309
- }
5310
- transform = (transform || 'none').trim();
5311
- if (transform === 'none') {
5277
+ function parseTransformUnmemoize(string) {
5278
+ string = (string || 'none').toLowerCase().trim();
5279
+ if (string === 'none') {
5312
5280
  return [];
5313
5281
  }
5282
+ var transformRegExp = /\s*(\w+)\(([^)]*)\)/g;
5314
5283
  var result = [];
5315
5284
  var match;
5316
5285
  var prevLastIndex = 0;
5317
- while ((match = TRANSFORM_REGEXP.exec(transform))) {
5286
+ while ((match = transformRegExp.exec(string))) {
5318
5287
  if (match.index !== prevLastIndex) {
5319
5288
  return [];
5320
5289
  }
@@ -5361,7 +5330,7 @@ function parseTransformUnmemoize(transform) {
5361
5330
  parsedArgs.push(parsedArg);
5362
5331
  }
5363
5332
  result.push({ t: functionName, d: parsedArgs }); // { t: scale, d: [1, 2] }
5364
- if (TRANSFORM_REGEXP.lastIndex === transform.length) {
5333
+ if (transformRegExp.lastIndex === string.length) {
5365
5334
  return result;
5366
5335
  }
5367
5336
  }
@@ -5373,7 +5342,7 @@ function convertItemToMatrix(item) {
5373
5342
  var z;
5374
5343
  var angle;
5375
5344
  switch (item.t) {
5376
- case 'rotateX':
5345
+ case 'rotatex':
5377
5346
  angle = deg2rad(convertAngleUnit(item.d[0]));
5378
5347
  return [
5379
5348
  1,
@@ -5393,7 +5362,7 @@ function convertItemToMatrix(item) {
5393
5362
  0,
5394
5363
  1,
5395
5364
  ];
5396
- case 'rotateY':
5365
+ case 'rotatey':
5397
5366
  angle = deg2rad(convertAngleUnit(item.d[0]));
5398
5367
  return [
5399
5368
  Math.cos(angle),
@@ -5414,7 +5383,7 @@ function convertItemToMatrix(item) {
5414
5383
  1,
5415
5384
  ];
5416
5385
  case 'rotate':
5417
- case 'rotateZ':
5386
+ case 'rotatez':
5418
5387
  angle = deg2rad(convertAngleUnit(item.d[0]));
5419
5388
  return [
5420
5389
  Math.cos(angle),
@@ -5491,11 +5460,11 @@ function convertItemToMatrix(item) {
5491
5460
  0,
5492
5461
  1,
5493
5462
  ];
5494
- case 'scaleX':
5463
+ case 'scalex':
5495
5464
  return [item.d[0].value, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
5496
- case 'scaleY':
5465
+ case 'scaley':
5497
5466
  return [1, 0, 0, 0, 0, item.d[0].value, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
5498
- case 'scaleZ':
5467
+ case 'scalez':
5499
5468
  return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, item.d[0].value, 0, 0, 0, 0, 1];
5500
5469
  case 'scale3d':
5501
5470
  return [
@@ -5537,10 +5506,10 @@ function convertItemToMatrix(item) {
5537
5506
  0,
5538
5507
  1,
5539
5508
  ];
5540
- case 'skewX':
5509
+ case 'skewx':
5541
5510
  angle = deg2rad(convertAngleUnit(item.d[0]));
5542
5511
  return [1, 0, 0, 0, Math.tan(angle), 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
5543
- case 'skewY':
5512
+ case 'skewy':
5544
5513
  angle = deg2rad(convertAngleUnit(item.d[0]));
5545
5514
  return [1, Math.tan(angle), 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
5546
5515
  case 'translate':
@@ -5548,13 +5517,13 @@ function convertItemToMatrix(item) {
5548
5517
  x = convertPercentUnit(item.d[0], 0, null) || 0;
5549
5518
  y = convertPercentUnit(item.d[1], 0, null) || 0;
5550
5519
  return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, x, y, 0, 1];
5551
- case 'translateX':
5520
+ case 'translatex':
5552
5521
  x = convertPercentUnit(item.d[0], 0, null) || 0;
5553
5522
  return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, x, 0, 0, 1];
5554
- case 'translateY':
5523
+ case 'translatey':
5555
5524
  y = convertPercentUnit(item.d[0], 0, null) || 0;
5556
5525
  return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, y, 0, 1];
5557
- case 'translateZ':
5526
+ case 'translatez':
5558
5527
  z = convertPercentUnit(item.d[0], 0, null) || 0;
5559
5528
  return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, z, 1];
5560
5529
  case 'translate3d':
@@ -5795,13 +5764,13 @@ function quat(fromQ, toQ, f) {
5795
5764
  }
5796
5765
  return quat;
5797
5766
  }
5798
- // scaleX/Y/Z -> scale
5767
+ // scalex/y/z -> scale
5799
5768
  function typeTo2D(type) {
5800
- return type.replace(/[XY]/, '');
5769
+ return type.replace(/[xy]/, '');
5801
5770
  }
5802
- // scaleX/Y/Z -> scale3d
5771
+ // scalex/y/z -> scale3d
5803
5772
  function typeTo3D(type) {
5804
- return type.replace(/(X|Y|Z|3d)?$/, '3d');
5773
+ return type.replace(/(x|y|z|3d)?$/, '3d');
5805
5774
  }
5806
5775
  var isMatrixOrPerspective = function (lt, rt) {
5807
5776
  return ((lt === 'perspective' && rt === 'perspective') ||
@@ -7935,15 +7904,15 @@ function parsedTransformToMat4(transform, object) {
7935
7904
  ];
7936
7905
  mat4.fromScaling(tmpMat2, [newScale[0], newScale[1], 1]);
7937
7906
  }
7938
- else if (t === 'scaleX') {
7907
+ else if (t === 'scalex') {
7939
7908
  var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return Math.max(s.value, SCALE_EPSILON); })) || [1];
7940
7909
  mat4.fromScaling(tmpMat2, [newScale[0], 1, 1]);
7941
7910
  }
7942
- else if (t === 'scaleY') {
7911
+ else if (t === 'scaley') {
7943
7912
  var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return Math.max(s.value, SCALE_EPSILON); })) || [1];
7944
7913
  mat4.fromScaling(tmpMat2, [1, newScale[0], 1]);
7945
7914
  }
7946
- else if (t === 'scaleZ') {
7915
+ else if (t === 'scalez') {
7947
7916
  var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return Math.max(s.value, SCALE_EPSILON); })) || [1];
7948
7917
  mat4.fromScaling(tmpMat2, [1, 1, newScale[0]]);
7949
7918
  }
@@ -7961,15 +7930,15 @@ function parsedTransformToMat4(transform, object) {
7961
7930
  0,
7962
7931
  ]);
7963
7932
  }
7964
- else if (t === 'translateX') {
7933
+ else if (t === 'translatex') {
7965
7934
  var newTranslation = d || [Opx];
7966
7935
  mat4.fromTranslation(tmpMat2, [newTranslation[0].value, 0, 0]);
7967
7936
  }
7968
- else if (t === 'translateY') {
7937
+ else if (t === 'translatey') {
7969
7938
  var newTranslation = d || [Opx];
7970
7939
  mat4.fromTranslation(tmpMat2, [0, newTranslation[0].value, 0]);
7971
7940
  }
7972
- else if (t === 'translateZ') {
7941
+ else if (t === 'translatez') {
7973
7942
  var newTranslation = d || [Opx];
7974
7943
  mat4.fromTranslation(tmpMat2, [0, 0, newTranslation[0].value]);
7975
7944
  }
@@ -7985,15 +7954,15 @@ function parsedTransformToMat4(transform, object) {
7985
7954
  var newAngles = d || [Odeg];
7986
7955
  mat4.fromZRotation(tmpMat2, deg2rad(convertAngleUnit(newAngles[0])));
7987
7956
  }
7988
- else if (t === 'rotateX') {
7957
+ else if (t === 'rotatex') {
7989
7958
  var newAngles = d || [Odeg];
7990
7959
  mat4.fromXRotation(tmpMat2, deg2rad(convertAngleUnit(newAngles[0])));
7991
7960
  }
7992
- else if (t === 'rotateY') {
7961
+ else if (t === 'rotatey') {
7993
7962
  var newAngles = d || [Odeg];
7994
7963
  mat4.fromYRotation(tmpMat2, deg2rad(convertAngleUnit(newAngles[0])));
7995
7964
  }
7996
- else if (t === 'rotateZ') {
7965
+ else if (t === 'rotatez') {
7997
7966
  var newAngles = d || [Odeg];
7998
7967
  mat4.fromZRotation(tmpMat2, deg2rad(convertAngleUnit(newAngles[0])));
7999
7968
  }
@@ -8009,11 +7978,11 @@ function parsedTransformToMat4(transform, object) {
8009
7978
  var newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [0, 0];
8010
7979
  createSkewMatrix(tmpMat2, deg2rad(newSkew[0]), deg2rad(newSkew[1]));
8011
7980
  }
8012
- else if (t === 'skewX') {
7981
+ else if (t === 'skewx') {
8013
7982
  var newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [0];
8014
7983
  createSkewMatrix(tmpMat2, deg2rad(newSkew[0]), 0);
8015
7984
  }
8016
- else if (t === 'skewY') {
7985
+ else if (t === 'skewy') {
8017
7986
  var newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [0];
8018
7987
  createSkewMatrix(tmpMat2, 0, deg2rad(newSkew[0]));
8019
7988
  }
@@ -10103,12 +10072,6 @@ var RenderingService = /** @class */ (function () {
10103
10072
  */
10104
10073
  rendered: 0,
10105
10074
  };
10106
- /**
10107
- * frame counter
10108
- * - 1 - init root container
10109
- * - 2 - user first frame
10110
- */
10111
- this.frame = 0;
10112
10075
  this.zIndexCounter = 0;
10113
10076
  this.hooks = {
10114
10077
  /**
@@ -10201,12 +10164,9 @@ var RenderingService = /** @class */ (function () {
10201
10164
  this.stats.total = 0;
10202
10165
  this.stats.rendered = 0;
10203
10166
  this.zIndexCounter = 0;
10204
- this.frame++;
10205
10167
  var renderingContext = this.context.renderingContext;
10206
10168
  this.globalRuntime.sceneGraphService.syncHierarchy(renderingContext.root);
10207
- if (this.frame > 2) {
10208
- this.globalRuntime.sceneGraphService.triggerPendingEvents(this.frame === 3 ? renderingContext.root : undefined);
10209
- }
10169
+ this.globalRuntime.sceneGraphService.triggerPendingEvents();
10210
10170
  if (renderingContext.renderReasons.size && this.inited) {
10211
10171
  // @ts-ignore
10212
10172
  renderingContext.dirtyRectangleRenderingDisabled =
@@ -10511,19 +10471,6 @@ function markRenderableDirty(e) {
10511
10471
  }
10512
10472
  }
10513
10473
  var reparentEvent = new MutationEvent(ElementEvent.REPARENT, null, '', '', '', 0, '', '');
10514
- var EPSILON = 0.000001;
10515
- /**
10516
- * an optimized version of gl-matrix's equals
10517
- */
10518
- function equals(a, b) {
10519
- var a0 = a[0], a1 = a[1], a2 = a[2];
10520
- var b0 = b[0], b1 = b[1], b2 = b[2];
10521
- if (a0 === b0 && a1 === b1 && a2 === b2)
10522
- return true;
10523
- return (Math.abs(a0 - b0) <= EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) &&
10524
- Math.abs(a1 - b1) <= EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) &&
10525
- Math.abs(a2 - b2) <= EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)));
10526
- }
10527
10474
  /**
10528
10475
  * update transform in scene graph
10529
10476
  *
@@ -10635,7 +10582,7 @@ var DefaultSceneGraphService = /** @class */ (function () {
10635
10582
  translation = vec3.fromValues(translation, y, z);
10636
10583
  }
10637
10584
  var transform = element.transformable;
10638
- if (equals(translation, vec3.create())) {
10585
+ if (vec3.equals(translation, vec3.create())) {
10639
10586
  return;
10640
10587
  }
10641
10588
  vec3.transformQuat(translation, translation, transform.localRotation);
@@ -10660,7 +10607,7 @@ var DefaultSceneGraphService = /** @class */ (function () {
10660
10607
  tmpPosition[0] = position[0];
10661
10608
  tmpPosition[1] = position[1];
10662
10609
  tmpPosition[2] = position[2] || 0;
10663
- if (equals(_this.getPosition(element), tmpPosition)) {
10610
+ if (vec3.equals(_this.getPosition(element), tmpPosition)) {
10664
10611
  return;
10665
10612
  }
10666
10613
  vec3.copy(transform.position, tmpPosition);
@@ -10690,7 +10637,7 @@ var DefaultSceneGraphService = /** @class */ (function () {
10690
10637
  tmpPosition[0] = position[0];
10691
10638
  tmpPosition[1] = position[1];
10692
10639
  tmpPosition[2] = position[2] || 0;
10693
- if (equals(transform.localPosition, tmpPosition)) {
10640
+ if (vec3.equals(transform.localPosition, tmpPosition)) {
10694
10641
  return;
10695
10642
  }
10696
10643
  vec3.copy(transform.localPosition, tmpPosition);
@@ -10722,7 +10669,7 @@ var DefaultSceneGraphService = /** @class */ (function () {
10722
10669
  if (typeof translation === 'number') {
10723
10670
  translation = vec3.set(tmpVec3, translation, y, z);
10724
10671
  }
10725
- if (equals(translation, zeroVec3)) {
10672
+ if (vec3.equals(translation, zeroVec3)) {
10726
10673
  return;
10727
10674
  }
10728
10675
  vec3.add(tr, _this.getPosition(element), translation);
@@ -10753,7 +10700,6 @@ var DefaultSceneGraphService = /** @class */ (function () {
10753
10700
  }
10754
10701
  };
10755
10702
  };
10756
- this.eventEntitySet = new Set();
10757
10703
  this.displayObjectDependencyMap = new WeakMap();
10758
10704
  this.calcLocalTransform = (function () {
10759
10705
  var tmpMat = mat4.create();
@@ -10921,7 +10867,7 @@ var DefaultSceneGraphService = /** @class */ (function () {
10921
10867
  if (dirtify === void 0) { dirtify = true; }
10922
10868
  var transform = element.transformable;
10923
10869
  var updatedScaling = vec3.fromValues(scaling[0], scaling[1], scaling[2] || transform.localScale[2]);
10924
- if (equals(updatedScaling, transform.localScale)) {
10870
+ if (vec3.equals(updatedScaling, transform.localScale)) {
10925
10871
  return;
10926
10872
  }
10927
10873
  vec3.copy(transform.localScale, updatedScaling);
@@ -10963,47 +10909,35 @@ var DefaultSceneGraphService = /** @class */ (function () {
10963
10909
  this.dirtifyWorldInternal(element, transform);
10964
10910
  this.dirtifyToRoot(element, true);
10965
10911
  };
10966
- DefaultSceneGraphService.prototype.triggerEvent = function (element, detail) {
10967
- if (element.isConnected && !this.eventEntitySet.has(element.entity)) {
10968
- this.boundsChangedEvent.detail = detail;
10969
- this.boundsChangedEvent.target = element;
10970
- if (element.isMutationObserved) {
10971
- element.dispatchEvent(this.boundsChangedEvent);
10972
- }
10973
- else {
10974
- element.ownerDocument.defaultView.dispatchEvent(this.boundsChangedEvent, true);
10975
- }
10976
- this.eventEntitySet.add(element.entity);
10977
- }
10978
- };
10979
- DefaultSceneGraphService.prototype.triggerPendingEvents = function (root) {
10912
+ DefaultSceneGraphService.prototype.triggerPendingEvents = function () {
10980
10913
  var _this = this;
10981
- if (root) {
10982
- root.forEach(function (e) {
10983
- _this.triggerEvent(e, { affectChildren: true });
10984
- });
10985
- }
10986
- else {
10987
- var events = this.pendingEvents;
10988
- var length_1 = events.length;
10989
- var _loop_1 = function (i) {
10990
- var _a = __read(events[i], 2), element = _a[0], detail = _a[1];
10991
- if (detail.affectChildren) {
10992
- element.forEach(function (e) {
10993
- _this.triggerEvent(e, detail);
10994
- });
10914
+ var set = new Set();
10915
+ var trigger = function (element, detail) {
10916
+ if (element.isConnected && !set.has(element.entity)) {
10917
+ _this.boundsChangedEvent.detail = detail;
10918
+ _this.boundsChangedEvent.target = element;
10919
+ if (element.isMutationObserved) {
10920
+ element.dispatchEvent(_this.boundsChangedEvent);
10995
10921
  }
10996
10922
  else {
10997
- this_1.triggerEvent(element, detail);
10923
+ element.ownerDocument.defaultView.dispatchEvent(_this.boundsChangedEvent, true);
10998
10924
  }
10999
- };
11000
- var this_1 = this;
11001
- for (var i = 0; i < length_1; i++) {
11002
- _loop_1(i);
10925
+ set.add(element.entity);
11003
10926
  }
11004
- }
11005
- this.eventEntitySet.clear();
10927
+ };
10928
+ this.pendingEvents.forEach(function (_a) {
10929
+ var _b = __read(_a, 2), element = _b[0], detail = _b[1];
10930
+ if (detail.affectChildren) {
10931
+ element.forEach(function (e) {
10932
+ trigger(e, detail);
10933
+ });
10934
+ }
10935
+ else {
10936
+ trigger(element, detail);
10937
+ }
10938
+ });
11006
10939
  this.clearPendingEvents();
10940
+ set.clear();
11007
10941
  };
11008
10942
  DefaultSceneGraphService.prototype.clearPendingEvents = function () {
11009
10943
  this.pendingEvents = [];
@@ -11111,9 +11045,9 @@ var DefaultSceneGraphService = /** @class */ (function () {
11111
11045
  return transform.localTransform;
11112
11046
  };
11113
11047
  DefaultSceneGraphService.prototype.setLocalTransform = function (element, transform) {
11114
- var t = mat4.getTranslation([0, 0, 0], transform);
11115
- var r = mat4.getRotation([0, 0, 0, 1], transform);
11116
- var s = mat4.getScaling([0, 0, 0], transform);
11048
+ var t = mat4.getTranslation(vec3.create(), transform);
11049
+ var r = mat4.getRotation(quat$1.create(), transform);
11050
+ var s = mat4.getScaling(vec3.create(), transform);
11117
11051
  this.setLocalScale(element, s, false);
11118
11052
  this.setLocalPosition(element, t, false);
11119
11053
  this.setLocalRotation(element, r, undefined, undefined, undefined, false);
@@ -14865,6 +14799,7 @@ var PrepareRendererPlugin = /** @class */ (function () {
14865
14799
  * sync to RBush later
14866
14800
  */
14867
14801
  this.toSync = new Set();
14802
+ this.isFirstTimeRendering = true;
14868
14803
  this.syncing = false;
14869
14804
  this.isFirstTimeRenderingFinished = false;
14870
14805
  }
@@ -14934,9 +14869,8 @@ var PrepareRendererPlugin = /** @class */ (function () {
14934
14869
  });
14935
14870
  var ric = (_a = runtime.globalThis.requestIdleCallback) !== null && _a !== void 0 ? _a : raf.bind(runtime.globalThis);
14936
14871
  renderingService.hooks.endFrame.tap(PrepareRendererPlugin.tag, function () {
14937
- var frame = context.renderingService.frame;
14938
- if (frame === 1) ;
14939
- else if (frame === 2) {
14872
+ if (_this.isFirstTimeRendering) {
14873
+ _this.isFirstTimeRendering = false;
14940
14874
  _this.syncing = true;
14941
14875
  ric(function () {
14942
14876
  _this.syncRTree(true);
@@ -14957,12 +14891,13 @@ var PrepareRendererPlugin = /** @class */ (function () {
14957
14891
  this.syncing = true;
14958
14892
  // bounds changed, need re-inserting its children
14959
14893
  var bulk = [];
14960
- this.toSync.forEach(function (node) {
14961
- if (node.isConnected)
14962
- return;
14894
+ Array.from(this.toSync)
14895
+ // some objects may be removed since last frame
14896
+ .filter(function (object) { return object.isConnected; })
14897
+ .forEach(function (node) {
14963
14898
  var rBushNode = node.rBushNode;
14964
14899
  // clear dirty node
14965
- if (rBushNode === null || rBushNode === void 0 ? void 0 : rBushNode.aabb) {
14900
+ if (rBushNode && rBushNode.aabb) {
14966
14901
  _this.rBush.remove(rBushNode.aabb);
14967
14902
  }
14968
14903
  var renderBounds = node.getRenderBounds();
@@ -15369,13 +15304,13 @@ var Canvas = /** @class */ (function (_super) {
15369
15304
  });
15370
15305
  }
15371
15306
  };
15372
- Canvas.prototype.initRenderingService = function (renderer, firstContentfulPaint, async) {
15307
+ Canvas.prototype.initRenderingService = function (renderer, firstContentfullPaint, async) {
15373
15308
  var _this = this;
15374
- if (firstContentfulPaint === void 0) { firstContentfulPaint = false; }
15309
+ if (firstContentfullPaint === void 0) { firstContentfullPaint = false; }
15375
15310
  if (async === void 0) { async = false; }
15376
15311
  this.context.renderingService.init(function () {
15377
15312
  _this.inited = true;
15378
- if (firstContentfulPaint) {
15313
+ if (firstContentfullPaint) {
15379
15314
  if (async) {
15380
15315
  _this.requestAnimationFrame(function () {
15381
15316
  _this.dispatchEvent(new CustomEvent(CanvasEvent.READY));
@@ -15391,7 +15326,7 @@ var Canvas = /** @class */ (function (_super) {
15391
15326
  if (_this.readyPromise) {
15392
15327
  _this.resolveReadyPromise();
15393
15328
  }
15394
- if (!firstContentfulPaint) {
15329
+ if (!firstContentfullPaint) {
15395
15330
  _this.getRoot().forEach(function (node) {
15396
15331
  var renderable = node.renderable;
15397
15332
  if (renderable) {