@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.
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var glMatrix = require('gl-matrix');
4
3
  var tslib = require('tslib');
5
4
  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,8 +26,6 @@ function _interopNamespaceDefault(e) {
26
26
 
27
27
  var d3__namespace = /*#__PURE__*/_interopNamespaceDefault(d3);
28
28
 
29
- glMatrix.glMatrix.setMatrixArrayType(Array);
30
-
31
29
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
32
30
 
33
31
  var rbush = {exports: {}};
@@ -664,7 +662,7 @@ var AbstractRenderer = /** @class */ (function () {
664
662
  /**
665
663
  * enable dirty rectangle rendering by default
666
664
  */
667
- enableDirtyRectangleRendering: true, enableDirtyRectangleRenderingDebug: false, enableSizeAttenuation: true, imageSmoothingEnabled: true, imageSmoothingQuality: 'high' }, config);
665
+ enableDirtyRectangleRendering: true, enableDirtyRectangleRenderingDebug: false, enableSizeAttenuation: true }, config);
668
666
  }
669
667
  AbstractRenderer.prototype.registerPlugin = function (plugin) {
670
668
  var index = this.plugins.findIndex(function (p) { return p === plugin; });
@@ -3129,25 +3127,25 @@ var CSSUnitValue = /** @class */ (function (_super) {
3129
3127
  case exports.UnitType.kSeconds:
3130
3128
  // case UnitType.kHertz:
3131
3129
  // case UnitType.kKilohertz:
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);
3130
+ case exports.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:
3131
+ {
3132
+ var kMinInteger = -999999;
3133
+ var kMaxInteger = 999999;
3134
+ var value = this.value;
3135
+ var unit = unitTypeToString(this.unit);
3136
+ if (value < kMinInteger || value > kMaxInteger) {
3137
+ var unit_1 = unitTypeToString(this.unit);
3138
+ if (!Number.isFinite(value) || Number.isNaN(value)) {
3139
+ text = formatInfinityOrNaN(value, unit_1);
3140
+ }
3141
+ else {
3142
+ text = value + (unit_1 || '');
3143
+ }
3142
3144
  }
3143
3145
  else {
3144
- text = value + (unit_1 || '');
3146
+ text = "".concat(value).concat(unit);
3145
3147
  }
3146
3148
  }
3147
- else {
3148
- text = "".concat(value).concat(unit);
3149
- }
3150
- }
3151
3149
  }
3152
3150
  result += text;
3153
3151
  return result;
@@ -3155,6 +3153,7 @@ var CSSUnitValue = /** @class */ (function (_super) {
3155
3153
  return CSSUnitValue;
3156
3154
  }(CSSStyleValue));
3157
3155
  var Opx = new CSSUnitValue(0, 'px');
3156
+ new CSSUnitValue(1, 'px');
3158
3157
  var Odeg = new CSSUnitValue(0, 'deg');
3159
3158
 
3160
3159
  /**
@@ -5184,7 +5183,6 @@ function mergePoints(left, right) {
5184
5183
  }
5185
5184
 
5186
5185
  var _ = null;
5187
- var TRANSFORM_REGEXP = /\s*(\w+)\(([^)]*)\)/g;
5188
5186
  function cast(pattern) {
5189
5187
  return function (contents) {
5190
5188
  var i = 0;
@@ -5203,75 +5201,48 @@ var transformFunctions = {
5203
5201
  matrix: ['NNNNNN', [_, _, 0, 0, _, _, 0, 0, 0, 0, 1, 0, _, _, 0, 1], id],
5204
5202
  matrix3d: ['NNNNNNNNNNNNNNNN', id],
5205
5203
  rotate: ['A'],
5206
- rotateX: ['A'],
5207
- rotateY: ['A'],
5208
- rotateZ: ['A'],
5204
+ rotatex: ['A'],
5205
+ rotatey: ['A'],
5206
+ rotatez: ['A'],
5209
5207
  rotate3d: ['NNNA'],
5210
5208
  perspective: ['L'],
5211
5209
  scale: ['Nn', cast([_, _, new CSSUnitValue(1)]), id],
5212
- scaleX: [
5210
+ scalex: [
5213
5211
  'N',
5214
5212
  cast([_, new CSSUnitValue(1), new CSSUnitValue(1)]),
5215
5213
  cast([_, new CSSUnitValue(1)]),
5216
5214
  ],
5217
- scaleY: [
5215
+ scaley: [
5218
5216
  'N',
5219
5217
  cast([new CSSUnitValue(1), _, new CSSUnitValue(1)]),
5220
5218
  cast([new CSSUnitValue(1), _]),
5221
5219
  ],
5222
- scaleZ: ['N', cast([new CSSUnitValue(1), new CSSUnitValue(1), _])],
5220
+ scalez: ['N', cast([new CSSUnitValue(1), new CSSUnitValue(1), _])],
5223
5221
  scale3d: ['NNN', id],
5224
5222
  skew: ['Aa', null, id],
5225
- skewX: ['A', null, cast([_, Odeg])],
5226
- skewY: ['A', null, cast([Odeg, _])],
5223
+ skewx: ['A', null, cast([_, Odeg])],
5224
+ skewy: ['A', null, cast([Odeg, _])],
5227
5225
  translate: ['Tt', cast([_, _, Opx]), id],
5228
- translateX: ['T', cast([_, Opx, Opx]), cast([_, Opx])],
5229
- translateY: ['T', cast([Opx, _, Opx]), cast([Opx, _])],
5230
- translateZ: ['L', cast([Opx, Opx, _])],
5226
+ translatex: ['T', cast([_, Opx, Opx]), cast([_, Opx])],
5227
+ translatey: ['T', cast([Opx, _, Opx]), cast([Opx, _])],
5228
+ translatez: ['L', cast([Opx, Opx, _])],
5231
5229
  translate3d: ['TTL', id],
5232
5230
  };
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
- }
5257
5231
  /**
5258
5232
  * none
5259
5233
  * scale(1) scale(1, 2)
5260
5234
  * scaleX(1)
5261
5235
  */
5262
- function parseTransform(transform) {
5263
- if (Array.isArray(transform)) {
5264
- return parseArrayTransform(transform);
5265
- }
5266
- transform = (transform || 'none').trim();
5267
- if (transform === 'none') {
5236
+ function parseTransform(string) {
5237
+ string = (string || 'none').toLowerCase().trim();
5238
+ if (string === 'none') {
5268
5239
  return [];
5269
5240
  }
5241
+ var transformRegExp = /\s*(\w+)\(([^)]*)\)/g;
5270
5242
  var result = [];
5271
5243
  var match;
5272
5244
  var prevLastIndex = 0;
5273
- TRANSFORM_REGEXP.lastIndex = 0;
5274
- while ((match = TRANSFORM_REGEXP.exec(transform))) {
5245
+ while ((match = transformRegExp.exec(string))) {
5275
5246
  if (match.index !== prevLastIndex) {
5276
5247
  return [];
5277
5248
  }
@@ -5318,24 +5289,22 @@ function parseTransform(transform) {
5318
5289
  parsedArgs.push(parsedArg);
5319
5290
  }
5320
5291
  result.push({ t: functionName, d: parsedArgs }); // { t: scale, d: [1, 2] }
5321
- if (TRANSFORM_REGEXP.lastIndex === transform.length) {
5292
+ if (transformRegExp.lastIndex === string.length) {
5322
5293
  return result;
5323
5294
  }
5324
5295
  }
5325
5296
  return [];
5326
5297
  }
5327
- function parseTransformUnmemoize(transform) {
5328
- if (Array.isArray(transform)) {
5329
- return parseArrayTransform(transform);
5330
- }
5331
- transform = (transform || 'none').trim();
5332
- if (transform === 'none') {
5298
+ function parseTransformUnmemoize(string) {
5299
+ string = (string || 'none').toLowerCase().trim();
5300
+ if (string === 'none') {
5333
5301
  return [];
5334
5302
  }
5303
+ var transformRegExp = /\s*(\w+)\(([^)]*)\)/g;
5335
5304
  var result = [];
5336
5305
  var match;
5337
5306
  var prevLastIndex = 0;
5338
- while ((match = TRANSFORM_REGEXP.exec(transform))) {
5307
+ while ((match = transformRegExp.exec(string))) {
5339
5308
  if (match.index !== prevLastIndex) {
5340
5309
  return [];
5341
5310
  }
@@ -5382,7 +5351,7 @@ function parseTransformUnmemoize(transform) {
5382
5351
  parsedArgs.push(parsedArg);
5383
5352
  }
5384
5353
  result.push({ t: functionName, d: parsedArgs }); // { t: scale, d: [1, 2] }
5385
- if (TRANSFORM_REGEXP.lastIndex === transform.length) {
5354
+ if (transformRegExp.lastIndex === string.length) {
5386
5355
  return result;
5387
5356
  }
5388
5357
  }
@@ -5394,7 +5363,7 @@ function convertItemToMatrix(item) {
5394
5363
  var z;
5395
5364
  var angle;
5396
5365
  switch (item.t) {
5397
- case 'rotateX':
5366
+ case 'rotatex':
5398
5367
  angle = deg2rad(convertAngleUnit(item.d[0]));
5399
5368
  return [
5400
5369
  1,
@@ -5414,7 +5383,7 @@ function convertItemToMatrix(item) {
5414
5383
  0,
5415
5384
  1,
5416
5385
  ];
5417
- case 'rotateY':
5386
+ case 'rotatey':
5418
5387
  angle = deg2rad(convertAngleUnit(item.d[0]));
5419
5388
  return [
5420
5389
  Math.cos(angle),
@@ -5435,7 +5404,7 @@ function convertItemToMatrix(item) {
5435
5404
  1,
5436
5405
  ];
5437
5406
  case 'rotate':
5438
- case 'rotateZ':
5407
+ case 'rotatez':
5439
5408
  angle = deg2rad(convertAngleUnit(item.d[0]));
5440
5409
  return [
5441
5410
  Math.cos(angle),
@@ -5512,11 +5481,11 @@ function convertItemToMatrix(item) {
5512
5481
  0,
5513
5482
  1,
5514
5483
  ];
5515
- case 'scaleX':
5484
+ case 'scalex':
5516
5485
  return [item.d[0].value, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
5517
- case 'scaleY':
5486
+ case 'scaley':
5518
5487
  return [1, 0, 0, 0, 0, item.d[0].value, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
5519
- case 'scaleZ':
5488
+ case 'scalez':
5520
5489
  return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, item.d[0].value, 0, 0, 0, 0, 1];
5521
5490
  case 'scale3d':
5522
5491
  return [
@@ -5558,10 +5527,10 @@ function convertItemToMatrix(item) {
5558
5527
  0,
5559
5528
  1,
5560
5529
  ];
5561
- case 'skewX':
5530
+ case 'skewx':
5562
5531
  angle = deg2rad(convertAngleUnit(item.d[0]));
5563
5532
  return [1, 0, 0, 0, Math.tan(angle), 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
5564
- case 'skewY':
5533
+ case 'skewy':
5565
5534
  angle = deg2rad(convertAngleUnit(item.d[0]));
5566
5535
  return [1, Math.tan(angle), 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
5567
5536
  case 'translate':
@@ -5569,13 +5538,13 @@ function convertItemToMatrix(item) {
5569
5538
  x = convertPercentUnit(item.d[0], 0, null) || 0;
5570
5539
  y = convertPercentUnit(item.d[1], 0, null) || 0;
5571
5540
  return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, x, y, 0, 1];
5572
- case 'translateX':
5541
+ case 'translatex':
5573
5542
  x = convertPercentUnit(item.d[0], 0, null) || 0;
5574
5543
  return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, x, 0, 0, 1];
5575
- case 'translateY':
5544
+ case 'translatey':
5576
5545
  y = convertPercentUnit(item.d[0], 0, null) || 0;
5577
5546
  return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, y, 0, 1];
5578
- case 'translateZ':
5547
+ case 'translatez':
5579
5548
  z = convertPercentUnit(item.d[0], 0, null) || 0;
5580
5549
  return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, z, 1];
5581
5550
  case 'translate3d':
@@ -5816,13 +5785,13 @@ function quat(fromQ, toQ, f) {
5816
5785
  }
5817
5786
  return quat;
5818
5787
  }
5819
- // scaleX/Y/Z -> scale
5788
+ // scalex/y/z -> scale
5820
5789
  function typeTo2D(type) {
5821
- return type.replace(/[XY]/, '');
5790
+ return type.replace(/[xy]/, '');
5822
5791
  }
5823
- // scaleX/Y/Z -> scale3d
5792
+ // scalex/y/z -> scale3d
5824
5793
  function typeTo3D(type) {
5825
- return type.replace(/(X|Y|Z|3d)?$/, '3d');
5794
+ return type.replace(/(x|y|z|3d)?$/, '3d');
5826
5795
  }
5827
5796
  var isMatrixOrPerspective = function (lt, rt) {
5828
5797
  return ((lt === 'perspective' && rt === 'perspective') ||
@@ -7956,15 +7925,15 @@ function parsedTransformToMat4(transform, object) {
7956
7925
  ];
7957
7926
  glMatrix.mat4.fromScaling(tmpMat2, [newScale[0], newScale[1], 1]);
7958
7927
  }
7959
- else if (t === 'scaleX') {
7928
+ else if (t === 'scalex') {
7960
7929
  var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return Math.max(s.value, SCALE_EPSILON); })) || [1];
7961
7930
  glMatrix.mat4.fromScaling(tmpMat2, [newScale[0], 1, 1]);
7962
7931
  }
7963
- else if (t === 'scaleY') {
7932
+ else if (t === 'scaley') {
7964
7933
  var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return Math.max(s.value, SCALE_EPSILON); })) || [1];
7965
7934
  glMatrix.mat4.fromScaling(tmpMat2, [1, newScale[0], 1]);
7966
7935
  }
7967
- else if (t === 'scaleZ') {
7936
+ else if (t === 'scalez') {
7968
7937
  var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return Math.max(s.value, SCALE_EPSILON); })) || [1];
7969
7938
  glMatrix.mat4.fromScaling(tmpMat2, [1, 1, newScale[0]]);
7970
7939
  }
@@ -7982,15 +7951,15 @@ function parsedTransformToMat4(transform, object) {
7982
7951
  0,
7983
7952
  ]);
7984
7953
  }
7985
- else if (t === 'translateX') {
7954
+ else if (t === 'translatex') {
7986
7955
  var newTranslation = d || [Opx];
7987
7956
  glMatrix.mat4.fromTranslation(tmpMat2, [newTranslation[0].value, 0, 0]);
7988
7957
  }
7989
- else if (t === 'translateY') {
7958
+ else if (t === 'translatey') {
7990
7959
  var newTranslation = d || [Opx];
7991
7960
  glMatrix.mat4.fromTranslation(tmpMat2, [0, newTranslation[0].value, 0]);
7992
7961
  }
7993
- else if (t === 'translateZ') {
7962
+ else if (t === 'translatez') {
7994
7963
  var newTranslation = d || [Opx];
7995
7964
  glMatrix.mat4.fromTranslation(tmpMat2, [0, 0, newTranslation[0].value]);
7996
7965
  }
@@ -8006,15 +7975,15 @@ function parsedTransformToMat4(transform, object) {
8006
7975
  var newAngles = d || [Odeg];
8007
7976
  glMatrix.mat4.fromZRotation(tmpMat2, deg2rad(convertAngleUnit(newAngles[0])));
8008
7977
  }
8009
- else if (t === 'rotateX') {
7978
+ else if (t === 'rotatex') {
8010
7979
  var newAngles = d || [Odeg];
8011
7980
  glMatrix.mat4.fromXRotation(tmpMat2, deg2rad(convertAngleUnit(newAngles[0])));
8012
7981
  }
8013
- else if (t === 'rotateY') {
7982
+ else if (t === 'rotatey') {
8014
7983
  var newAngles = d || [Odeg];
8015
7984
  glMatrix.mat4.fromYRotation(tmpMat2, deg2rad(convertAngleUnit(newAngles[0])));
8016
7985
  }
8017
- else if (t === 'rotateZ') {
7986
+ else if (t === 'rotatez') {
8018
7987
  var newAngles = d || [Odeg];
8019
7988
  glMatrix.mat4.fromZRotation(tmpMat2, deg2rad(convertAngleUnit(newAngles[0])));
8020
7989
  }
@@ -8030,11 +7999,11 @@ function parsedTransformToMat4(transform, object) {
8030
7999
  var newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [0, 0];
8031
8000
  createSkewMatrix(tmpMat2, deg2rad(newSkew[0]), deg2rad(newSkew[1]));
8032
8001
  }
8033
- else if (t === 'skewX') {
8002
+ else if (t === 'skewx') {
8034
8003
  var newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [0];
8035
8004
  createSkewMatrix(tmpMat2, deg2rad(newSkew[0]), 0);
8036
8005
  }
8037
- else if (t === 'skewY') {
8006
+ else if (t === 'skewy') {
8038
8007
  var newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [0];
8039
8008
  createSkewMatrix(tmpMat2, 0, deg2rad(newSkew[0]));
8040
8009
  }
@@ -10124,12 +10093,6 @@ var RenderingService = /** @class */ (function () {
10124
10093
  */
10125
10094
  rendered: 0,
10126
10095
  };
10127
- /**
10128
- * frame counter
10129
- * - 1 - init root container
10130
- * - 2 - user first frame
10131
- */
10132
- this.frame = 0;
10133
10096
  this.zIndexCounter = 0;
10134
10097
  this.hooks = {
10135
10098
  /**
@@ -10222,12 +10185,9 @@ var RenderingService = /** @class */ (function () {
10222
10185
  this.stats.total = 0;
10223
10186
  this.stats.rendered = 0;
10224
10187
  this.zIndexCounter = 0;
10225
- this.frame++;
10226
10188
  var renderingContext = this.context.renderingContext;
10227
10189
  this.globalRuntime.sceneGraphService.syncHierarchy(renderingContext.root);
10228
- if (this.frame > 2) {
10229
- this.globalRuntime.sceneGraphService.triggerPendingEvents(this.frame === 3 ? renderingContext.root : undefined);
10230
- }
10190
+ this.globalRuntime.sceneGraphService.triggerPendingEvents();
10231
10191
  if (renderingContext.renderReasons.size && this.inited) {
10232
10192
  // @ts-ignore
10233
10193
  renderingContext.dirtyRectangleRenderingDisabled =
@@ -10532,19 +10492,6 @@ function markRenderableDirty(e) {
10532
10492
  }
10533
10493
  }
10534
10494
  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
- }
10548
10495
  /**
10549
10496
  * update transform in scene graph
10550
10497
  *
@@ -10656,7 +10603,7 @@ var DefaultSceneGraphService = /** @class */ (function () {
10656
10603
  translation = glMatrix.vec3.fromValues(translation, y, z);
10657
10604
  }
10658
10605
  var transform = element.transformable;
10659
- if (equals(translation, glMatrix.vec3.create())) {
10606
+ if (glMatrix.vec3.equals(translation, glMatrix.vec3.create())) {
10660
10607
  return;
10661
10608
  }
10662
10609
  glMatrix.vec3.transformQuat(translation, translation, transform.localRotation);
@@ -10681,7 +10628,7 @@ var DefaultSceneGraphService = /** @class */ (function () {
10681
10628
  tmpPosition[0] = position[0];
10682
10629
  tmpPosition[1] = position[1];
10683
10630
  tmpPosition[2] = position[2] || 0;
10684
- if (equals(_this.getPosition(element), tmpPosition)) {
10631
+ if (glMatrix.vec3.equals(_this.getPosition(element), tmpPosition)) {
10685
10632
  return;
10686
10633
  }
10687
10634
  glMatrix.vec3.copy(transform.position, tmpPosition);
@@ -10711,7 +10658,7 @@ var DefaultSceneGraphService = /** @class */ (function () {
10711
10658
  tmpPosition[0] = position[0];
10712
10659
  tmpPosition[1] = position[1];
10713
10660
  tmpPosition[2] = position[2] || 0;
10714
- if (equals(transform.localPosition, tmpPosition)) {
10661
+ if (glMatrix.vec3.equals(transform.localPosition, tmpPosition)) {
10715
10662
  return;
10716
10663
  }
10717
10664
  glMatrix.vec3.copy(transform.localPosition, tmpPosition);
@@ -10743,7 +10690,7 @@ var DefaultSceneGraphService = /** @class */ (function () {
10743
10690
  if (typeof translation === 'number') {
10744
10691
  translation = glMatrix.vec3.set(tmpVec3, translation, y, z);
10745
10692
  }
10746
- if (equals(translation, zeroVec3)) {
10693
+ if (glMatrix.vec3.equals(translation, zeroVec3)) {
10747
10694
  return;
10748
10695
  }
10749
10696
  glMatrix.vec3.add(tr, _this.getPosition(element), translation);
@@ -10774,7 +10721,6 @@ var DefaultSceneGraphService = /** @class */ (function () {
10774
10721
  }
10775
10722
  };
10776
10723
  };
10777
- this.eventEntitySet = new Set();
10778
10724
  this.displayObjectDependencyMap = new WeakMap();
10779
10725
  this.calcLocalTransform = (function () {
10780
10726
  var tmpMat = glMatrix.mat4.create();
@@ -10942,7 +10888,7 @@ var DefaultSceneGraphService = /** @class */ (function () {
10942
10888
  if (dirtify === void 0) { dirtify = true; }
10943
10889
  var transform = element.transformable;
10944
10890
  var updatedScaling = glMatrix.vec3.fromValues(scaling[0], scaling[1], scaling[2] || transform.localScale[2]);
10945
- if (equals(updatedScaling, transform.localScale)) {
10891
+ if (glMatrix.vec3.equals(updatedScaling, transform.localScale)) {
10946
10892
  return;
10947
10893
  }
10948
10894
  glMatrix.vec3.copy(transform.localScale, updatedScaling);
@@ -10984,47 +10930,35 @@ var DefaultSceneGraphService = /** @class */ (function () {
10984
10930
  this.dirtifyWorldInternal(element, transform);
10985
10931
  this.dirtifyToRoot(element, true);
10986
10932
  };
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) {
10933
+ DefaultSceneGraphService.prototype.triggerPendingEvents = function () {
11001
10934
  var _this = this;
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
- });
10935
+ var set = new Set();
10936
+ var trigger = function (element, detail) {
10937
+ if (element.isConnected && !set.has(element.entity)) {
10938
+ _this.boundsChangedEvent.detail = detail;
10939
+ _this.boundsChangedEvent.target = element;
10940
+ if (element.isMutationObserved) {
10941
+ element.dispatchEvent(_this.boundsChangedEvent);
11016
10942
  }
11017
10943
  else {
11018
- this_1.triggerEvent(element, detail);
10944
+ element.ownerDocument.defaultView.dispatchEvent(_this.boundsChangedEvent, true);
11019
10945
  }
11020
- };
11021
- var this_1 = this;
11022
- for (var i = 0; i < length_1; i++) {
11023
- _loop_1(i);
10946
+ set.add(element.entity);
11024
10947
  }
11025
- }
11026
- this.eventEntitySet.clear();
10948
+ };
10949
+ this.pendingEvents.forEach(function (_a) {
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);
10958
+ }
10959
+ });
11027
10960
  this.clearPendingEvents();
10961
+ set.clear();
11028
10962
  };
11029
10963
  DefaultSceneGraphService.prototype.clearPendingEvents = function () {
11030
10964
  this.pendingEvents = [];
@@ -11132,9 +11066,9 @@ var DefaultSceneGraphService = /** @class */ (function () {
11132
11066
  return transform.localTransform;
11133
11067
  };
11134
11068
  DefaultSceneGraphService.prototype.setLocalTransform = function (element, transform) {
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);
11069
+ var t = glMatrix.mat4.getTranslation(glMatrix.vec3.create(), transform);
11070
+ var r = glMatrix.mat4.getRotation(glMatrix.quat.create(), transform);
11071
+ var s = glMatrix.mat4.getScaling(glMatrix.vec3.create(), transform);
11138
11072
  this.setLocalScale(element, s, false);
11139
11073
  this.setLocalPosition(element, t, false);
11140
11074
  this.setLocalRotation(element, r, undefined, undefined, undefined, false);
@@ -14886,6 +14820,7 @@ var PrepareRendererPlugin = /** @class */ (function () {
14886
14820
  * sync to RBush later
14887
14821
  */
14888
14822
  this.toSync = new Set();
14823
+ this.isFirstTimeRendering = true;
14889
14824
  this.syncing = false;
14890
14825
  this.isFirstTimeRenderingFinished = false;
14891
14826
  }
@@ -14955,9 +14890,8 @@ var PrepareRendererPlugin = /** @class */ (function () {
14955
14890
  });
14956
14891
  var ric = (_a = runtime.globalThis.requestIdleCallback) !== null && _a !== void 0 ? _a : raf.bind(runtime.globalThis);
14957
14892
  renderingService.hooks.endFrame.tap(PrepareRendererPlugin.tag, function () {
14958
- var frame = context.renderingService.frame;
14959
- if (frame === 1) ;
14960
- else if (frame === 2) {
14893
+ if (_this.isFirstTimeRendering) {
14894
+ _this.isFirstTimeRendering = false;
14961
14895
  _this.syncing = true;
14962
14896
  ric(function () {
14963
14897
  _this.syncRTree(true);
@@ -14978,12 +14912,13 @@ var PrepareRendererPlugin = /** @class */ (function () {
14978
14912
  this.syncing = true;
14979
14913
  // bounds changed, need re-inserting its children
14980
14914
  var bulk = [];
14981
- this.toSync.forEach(function (node) {
14982
- if (node.isConnected)
14983
- return;
14915
+ Array.from(this.toSync)
14916
+ // some objects may be removed since last frame
14917
+ .filter(function (object) { return object.isConnected; })
14918
+ .forEach(function (node) {
14984
14919
  var rBushNode = node.rBushNode;
14985
14920
  // clear dirty node
14986
- if (rBushNode === null || rBushNode === void 0 ? void 0 : rBushNode.aabb) {
14921
+ if (rBushNode && rBushNode.aabb) {
14987
14922
  _this.rBush.remove(rBushNode.aabb);
14988
14923
  }
14989
14924
  var renderBounds = node.getRenderBounds();
@@ -15390,13 +15325,13 @@ var Canvas = /** @class */ (function (_super) {
15390
15325
  });
15391
15326
  }
15392
15327
  };
15393
- Canvas.prototype.initRenderingService = function (renderer, firstContentfulPaint, async) {
15328
+ Canvas.prototype.initRenderingService = function (renderer, firstContentfullPaint, async) {
15394
15329
  var _this = this;
15395
- if (firstContentfulPaint === void 0) { firstContentfulPaint = false; }
15330
+ if (firstContentfullPaint === void 0) { firstContentfullPaint = false; }
15396
15331
  if (async === void 0) { async = false; }
15397
15332
  this.context.renderingService.init(function () {
15398
15333
  _this.inited = true;
15399
- if (firstContentfulPaint) {
15334
+ if (firstContentfullPaint) {
15400
15335
  if (async) {
15401
15336
  _this.requestAnimationFrame(function () {
15402
15337
  _this.dispatchEvent(new CustomEvent(exports.CanvasEvent.READY));
@@ -15412,7 +15347,7 @@ var Canvas = /** @class */ (function (_super) {
15412
15347
  if (_this.readyPromise) {
15413
15348
  _this.resolveReadyPromise();
15414
15349
  }
15415
- if (!firstContentfulPaint) {
15350
+ if (!firstContentfullPaint) {
15416
15351
  _this.getRoot().forEach(function (node) {
15417
15352
  var renderable = node.renderable;
15418
15353
  if (renderable) {