@antv/g-lite 1.0.46 → 1.0.48

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.umd.js CHANGED
@@ -6991,6 +6991,7 @@
6991
6991
  }
6992
6992
  return new CSSUnitValue(value, unitOrName);
6993
6993
  };
6994
+ var PECENTAGE_50 = new CSSUnitValue(50, '%');
6994
6995
 
6995
6996
  function define(constructor, factory, prototype) {
6996
6997
  constructor.prototype = factory.prototype = prototype;
@@ -7405,8 +7406,8 @@
7405
7406
  function findClosestClipPathTarget(object) {
7406
7407
  var el = object;
7407
7408
  do {
7408
- var _el$style;
7409
- var clipPath = (_el$style = el.style) === null || _el$style === void 0 ? void 0 : _el$style.clipPath;
7409
+ var _el$parsedStyle;
7410
+ var clipPath = (_el$parsedStyle = el.parsedStyle) === null || _el$parsedStyle === void 0 ? void 0 : _el$parsedStyle.clipPath;
7410
7411
  if (clipPath) return el;
7411
7412
  el = el.parentElement;
7412
7413
  } while (el !== null);
@@ -10803,8 +10804,7 @@
10803
10804
  var fontSizeString = isNumber(fontSize) && fontSize + "px" || '16px';
10804
10805
  // Clean-up fontFamily property by quoting each font name
10805
10806
  // this will support font names with spaces
10806
- // @ts-ignore
10807
- var fontFamilies = isString(fontFamily) ? fontFamily.split(',') : [fontFamily];
10807
+ var fontFamilies = fontFamily.split(',');
10808
10808
  for (var i = fontFamilies.length - 1; i >= 0; i--) {
10809
10809
  // Trim any extra white-space
10810
10810
  var _fontFamily = fontFamilies[i].trim();
@@ -11213,698 +11213,281 @@
11213
11213
  }];
11214
11214
  }
11215
11215
 
11216
+ function parseDimension(unitRegExp, string) {
11217
+ if (isNil(string)) {
11218
+ return getOrCreateUnitValue(0, 'px');
11219
+ }
11220
+ string = ("" + string).trim().toLowerCase();
11221
+ if (isFinite(Number(string))) {
11222
+ if ('px'.search(unitRegExp) >= 0) {
11223
+ return getOrCreateUnitValue(Number(string), 'px');
11224
+ } else if ('deg'.search(unitRegExp) >= 0) {
11225
+ return getOrCreateUnitValue(Number(string), 'deg');
11226
+ }
11227
+ }
11228
+ var matchedUnits = [];
11229
+ string = string.replace(unitRegExp, function (match) {
11230
+ matchedUnits.push(match);
11231
+ return 'U' + match;
11232
+ });
11233
+ var taggedUnitRegExp = 'U(' + unitRegExp.source + ')';
11234
+ return matchedUnits.map(function (unit) {
11235
+ return getOrCreateUnitValue(Number(string.replace(new RegExp('U' + unit, 'g'), '').replace(new RegExp(taggedUnitRegExp, 'g'), '*0')), unit);
11236
+ })[0];
11237
+ }
11216
11238
  /**
11217
- * Axis-Aligned Bounding Box
11218
- * 为了便于后续 Frustum Culling,通过查找表定义 p-vertex 和 n-vertex
11219
- * @see https://github.com/antvis/GWebGPUEngine/issues/3
11239
+ * <length>
11240
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/length
11241
+ * length with only absolute unit, eg. 1px
11220
11242
  */
11221
- var AABB = /*#__PURE__*/function () {
11222
- AABB.isEmpty = function isEmpty(aabb) {
11223
- return !aabb || aabb.halfExtents[0] === 0 && aabb.halfExtents[1] === 0 && aabb.halfExtents[2] === 0;
11224
- };
11225
- // center: vec3 = vec3.create();
11226
- // halfExtents: vec3 = vec3.create();
11227
- // min: vec3 = vec3.create();
11228
- // max: vec3 = vec3.create();
11229
- function AABB(center, halfExtents) {
11230
- if (center === void 0) {
11231
- center = [0, 0, 0];
11232
- }
11233
- if (halfExtents === void 0) {
11234
- halfExtents = [0, 0, 0];
11235
- }
11236
- this.center = [0, 0, 0];
11237
- this.halfExtents = [0, 0, 0];
11238
- this.min = [0, 0, 0];
11239
- this.max = [0, 0, 0];
11240
- this.update(center, halfExtents);
11243
+ var parseLength = memoize(function (css) {
11244
+ return parseDimension(new RegExp('px', 'g'), css);
11245
+ });
11246
+ /**
11247
+ * <percentage>
11248
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/percentage
11249
+ */
11250
+ var parserPercentage = memoize(function (css) {
11251
+ return parseDimension(new RegExp('%', 'g'), css);
11252
+ });
11253
+ /**
11254
+ * length with absolute or relative unit,
11255
+ * eg. 1px, 0.7em, 50%, calc(100% - 200px);
11256
+ *
11257
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/length-percentage
11258
+ */
11259
+ // export const parseLengthOrPercentage = memoize((css: string): CSSUnitValue => {
11260
+ // if (isNumber(css) || isFinite(Number(css))) {
11261
+ // return getOrCreateUnitValue(Number(css), 'px');
11262
+ // }
11263
+ // return parseDimension(new RegExp('px|%|em|rem', 'g'), css) as CSSUnitValue;
11264
+ // });
11265
+ var parseLengthOrPercentage = function parseLengthOrPercentage(css) {
11266
+ if (isNumber(css) || isFinite(Number(css))) {
11267
+ // Number(css) is NaN
11268
+ return getOrCreateUnitValue(Number(css) || 0, 'px');
11269
+ // return Number(css);
11241
11270
  }
11242
- var _proto = AABB.prototype;
11243
- _proto.update = function update(center, halfExtents) {
11244
- copyVec3(this.center, center);
11245
- copyVec3(this.halfExtents, halfExtents);
11246
- subVec3(this.min, this.center, this.halfExtents);
11247
- addVec3(this.max, this.center, this.halfExtents);
11248
- // vec3.copy(this.center, center);
11249
- // vec3.copy(this.halfExtents, halfExtents);
11250
- // vec3.sub(this.min, this.center, this.halfExtents);
11251
- // vec3.add(this.max, this.center, this.halfExtents);
11252
- };
11253
- _proto.setMinMax = function setMinMax(min, max) {
11254
- // vec3.add(this.center, max, min);
11255
- // vec3.scale(this.center, this.center, 0.5);
11256
- // vec3.sub(this.halfExtents, max, min);
11257
- // vec3.scale(this.halfExtents, this.halfExtents, 0.5);
11258
- // vec3.copy(this.min, min);
11259
- // vec3.copy(this.max, max);
11260
- addVec3(this.center, max, min);
11261
- scaleVec3(this.center, this.center, 0.5);
11262
- subVec3(this.halfExtents, max, min);
11263
- scaleVec3(this.halfExtents, this.halfExtents, 0.5);
11264
- copyVec3(this.min, min);
11265
- copyVec3(this.max, max);
11266
- };
11267
- _proto.getMin = function getMin() {
11268
- return this.min;
11269
- };
11270
- _proto.getMax = function getMax() {
11271
- return this.max;
11272
- };
11273
- _proto.add = function add(aabb) {
11274
- if (AABB.isEmpty(aabb)) {
11275
- return;
11276
- }
11277
- if (AABB.isEmpty(this)) {
11278
- this.setMinMax(aabb.getMin(), aabb.getMax());
11279
- return;
11280
- }
11281
- var tc = this.center;
11282
- var tcx = tc[0];
11283
- var tcy = tc[1];
11284
- var tcz = tc[2];
11285
- var th = this.halfExtents;
11286
- var thx = th[0];
11287
- var thy = th[1];
11288
- var thz = th[2];
11289
- var tminx = tcx - thx;
11290
- var tmaxx = tcx + thx;
11291
- var tminy = tcy - thy;
11292
- var tmaxy = tcy + thy;
11293
- var tminz = tcz - thz;
11294
- var tmaxz = tcz + thz;
11295
- var oc = aabb.center;
11296
- var ocx = oc[0];
11297
- var ocy = oc[1];
11298
- var ocz = oc[2];
11299
- var oh = aabb.halfExtents;
11300
- var ohx = oh[0];
11301
- var ohy = oh[1];
11302
- var ohz = oh[2];
11303
- var ominx = ocx - ohx;
11304
- var omaxx = ocx + ohx;
11305
- var ominy = ocy - ohy;
11306
- var omaxy = ocy + ohy;
11307
- var ominz = ocz - ohz;
11308
- var omaxz = ocz + ohz;
11309
- if (ominx < tminx) {
11310
- tminx = ominx;
11311
- }
11312
- if (omaxx > tmaxx) {
11313
- tmaxx = omaxx;
11314
- }
11315
- if (ominy < tminy) {
11316
- tminy = ominy;
11271
+
11272
+ return parseDimension(new RegExp('px|%|em|rem', 'g'), css);
11273
+ };
11274
+ var parseAngle = memoize(function (css) {
11275
+ return parseDimension(new RegExp('deg|rad|grad|turn', 'g'), css);
11276
+ });
11277
+ /**
11278
+ * merge CSSUnitValue
11279
+ *
11280
+ * @example
11281
+ * 10px + 20px = 30px
11282
+ * 10deg + 10rad
11283
+ * 10% + 20% = 30%
11284
+ */
11285
+ function mergeDimensions(left, right, target, nonNegative, index) {
11286
+ if (index === void 0) {
11287
+ index = 0;
11288
+ }
11289
+ var unit = '';
11290
+ var leftValue = left.value || 0;
11291
+ var rightValue = right.value || 0;
11292
+ var canonicalUnit = toCanonicalUnit(left.unit);
11293
+ var leftCanonicalUnitValue = left.convertTo(canonicalUnit);
11294
+ var rightCanonicalUnitValue = right.convertTo(canonicalUnit);
11295
+ if (leftCanonicalUnitValue && rightCanonicalUnitValue) {
11296
+ leftValue = leftCanonicalUnitValue.value;
11297
+ rightValue = rightCanonicalUnitValue.value;
11298
+ unit = unitTypeToString(left.unit);
11299
+ } else {
11300
+ // format '%' to 'px'
11301
+ if (CSSUnitValue.isLength(left.unit) || CSSUnitValue.isLength(right.unit)) {
11302
+ leftValue = convertPercentUnit(left, index, target);
11303
+ rightValue = convertPercentUnit(right, index, target);
11304
+ unit = 'px';
11317
11305
  }
11318
- if (omaxy > tmaxy) {
11319
- tmaxy = omaxy;
11306
+ }
11307
+ // // format 'rad' 'turn' to 'deg'
11308
+ // if (CSSUnitValue.isAngle(left.unit) || CSSUnitValue.isAngle(right.unit)) {
11309
+ // leftValue = convertAngleUnit(left);
11310
+ // rightValue = convertAngleUnit(right);
11311
+ // unit = 'deg';
11312
+ // }
11313
+ return [leftValue, rightValue, function (value) {
11314
+ if (nonNegative) {
11315
+ value = Math.max(value, 0);
11320
11316
  }
11321
- if (ominz < tminz) {
11322
- tminz = ominz;
11317
+ return value + unit;
11318
+ }];
11319
+ }
11320
+ function convertAngleUnit(value) {
11321
+ var deg = 0;
11322
+ if (value.unit === exports.UnitType.kDegrees) {
11323
+ deg = value.value;
11324
+ } else if (value.unit === exports.UnitType.kRadians) {
11325
+ deg = rad2deg(Number(value.value));
11326
+ } else if (value.unit === exports.UnitType.kTurns) {
11327
+ deg = turn2deg(Number(value.value));
11328
+ }
11329
+ return deg;
11330
+ }
11331
+ function parseDimensionArrayFormat(string, size) {
11332
+ var parsed;
11333
+ if (Array.isArray(string)) {
11334
+ // [1, '2px', 3]
11335
+ parsed = string.map(function (segment) {
11336
+ return Number(segment);
11337
+ });
11338
+ } else if (isString(string)) {
11339
+ parsed = string.split(' ').map(function (segment) {
11340
+ return Number(segment);
11341
+ });
11342
+ } else if (isNumber(string)) {
11343
+ parsed = [string];
11344
+ }
11345
+ if (size === 2) {
11346
+ if (parsed.length === 1) {
11347
+ return [parsed[0], parsed[0]];
11348
+ } else {
11349
+ return [parsed[0], parsed[1]];
11323
11350
  }
11324
- if (omaxz > tmaxz) {
11325
- tmaxz = omaxz;
11351
+ } else {
11352
+ if (parsed.length === 1) {
11353
+ return [parsed[0], parsed[0], parsed[0], parsed[0]];
11354
+ } else if (parsed.length === 2) {
11355
+ return [parsed[0], parsed[1], parsed[0], parsed[1]];
11356
+ } else if (parsed.length === 3) {
11357
+ return [parsed[0], parsed[1], parsed[2], parsed[1]];
11358
+ } else {
11359
+ return [parsed[0], parsed[1], parsed[2], parsed[3]];
11326
11360
  }
11327
- tc[0] = (tminx + tmaxx) * 0.5;
11328
- tc[1] = (tminy + tmaxy) * 0.5;
11329
- tc[2] = (tminz + tmaxz) * 0.5;
11330
- th[0] = (tmaxx - tminx) * 0.5;
11331
- th[1] = (tmaxy - tminy) * 0.5;
11332
- th[2] = (tmaxz - tminz) * 0.5;
11333
- this.min[0] = tminx;
11334
- this.min[1] = tminy;
11335
- this.min[2] = tminz;
11336
- this.max[0] = tmaxx;
11337
- this.max[1] = tmaxy;
11338
- this.max[2] = tmaxz;
11339
- };
11340
- _proto.setFromTransformedAABB = function setFromTransformedAABB(aabb, m) {
11341
- var bc = this.center;
11342
- var br = this.halfExtents;
11343
- var ac = aabb.center;
11344
- var ar = aabb.halfExtents;
11345
- var mx0 = m[0];
11346
- var mx1 = m[4];
11347
- var mx2 = m[8];
11348
- var my0 = m[1];
11349
- var my1 = m[5];
11350
- var my2 = m[9];
11351
- var mz0 = m[2];
11352
- var mz1 = m[6];
11353
- var mz2 = m[10];
11354
- var mx0a = Math.abs(mx0);
11355
- var mx1a = Math.abs(mx1);
11356
- var mx2a = Math.abs(mx2);
11357
- var my0a = Math.abs(my0);
11358
- var my1a = Math.abs(my1);
11359
- var my2a = Math.abs(my2);
11360
- var mz0a = Math.abs(mz0);
11361
- var mz1a = Math.abs(mz1);
11362
- var mz2a = Math.abs(mz2);
11363
- bc[0] = m[12] + mx0 * ac[0] + mx1 * ac[1] + mx2 * ac[2];
11364
- bc[1] = m[13] + my0 * ac[0] + my1 * ac[1] + my2 * ac[2];
11365
- bc[2] = m[14] + mz0 * ac[0] + mz1 * ac[1] + mz2 * ac[2];
11366
- // vec3.set(
11367
- // bc,
11368
- // m[12] + mx0 * ac[0] + mx1 * ac[1] + mx2 * ac[2],
11369
- // m[13] + my0 * ac[0] + my1 * ac[1] + my2 * ac[2],
11370
- // m[14] + mz0 * ac[0] + mz1 * ac[1] + mz2 * ac[2],
11371
- // );
11372
- br[0] = mx0a * ar[0] + mx1a * ar[1] + mx2a * ar[2];
11373
- br[1] = my0a * ar[0] + my1a * ar[1] + my2a * ar[2];
11374
- br[2] = mz0a * ar[0] + mz1a * ar[1] + mz2a * ar[2];
11375
- // vec3.set(
11376
- // br,
11377
- // mx0a * ar[0] + mx1a * ar[1] + mx2a * ar[2],
11378
- // my0a * ar[0] + my1a * ar[1] + my2a * ar[2],
11379
- // mz0a * ar[0] + mz1a * ar[1] + mz2a * ar[2],
11380
- // );
11381
- // this.min = vec3.sub(this.min, bc, br);
11382
- // this.max = vec3.add(this.max, bc, br);
11383
- subVec3(this.min, bc, br);
11384
- addVec3(this.max, bc, br);
11385
- };
11386
- _proto.intersects = function intersects(aabb) {
11387
- var aMax = this.getMax();
11388
- var aMin = this.getMin();
11389
- var bMax = aabb.getMax();
11390
- var bMin = aabb.getMin();
11391
- return aMin[0] <= bMax[0] && aMax[0] >= bMin[0] && aMin[1] <= bMax[1] && aMax[1] >= bMin[1] && aMin[2] <= bMax[2] && aMax[2] >= bMin[2];
11392
- };
11393
- _proto.intersection = function intersection(aabb) {
11394
- if (!this.intersects(aabb)) {
11395
- return null;
11396
- }
11397
- var intersection = new AABB();
11398
- // const min = vec3.max(vec3.create(), this.getMin(), aabb.getMin());
11399
- // const max = vec3.min(vec3.create(), this.getMax(), aabb.getMax());
11400
- var min = maxVec3([0, 0, 0], this.getMin(), aabb.getMin());
11401
- var max = minVec3([0, 0, 0], this.getMax(), aabb.getMax());
11402
- intersection.setMinMax(min, max);
11403
- return intersection;
11404
11361
  }
11405
- // containsPoint(point: vec3) {
11406
- // const min = this.getMin();
11407
- // const max = this.getMax();
11408
- // return !(
11409
- // point[0] < min[0] ||
11410
- // point[0] > max[0] ||
11411
- // point[1] < min[1] ||
11412
- // point[1] > max[1] ||
11413
- // point[2] < min[2] ||
11414
- // point[2] > max[2]
11415
- // );
11416
- // }
11417
- /**
11418
- * get n-vertex
11419
- * @param plane plane of CullingVolume
11420
- */;
11421
- _proto.getNegativeFarPoint = function getNegativeFarPoint(plane) {
11422
- if (plane.pnVertexFlag === 0x111) {
11423
- return copyVec3([0, 0, 0], this.min);
11424
- // return vec3.copy(vec3.create(), this.min);
11425
- } else if (plane.pnVertexFlag === 0x110) {
11426
- return [this.min[0], this.min[1], this.max[2]];
11427
- // return vec3.fromValues(this.min[0], this.min[1], this.max[2]);
11428
- } else if (plane.pnVertexFlag === 0x101) {
11429
- return [this.min[0], this.max[1], this.min[2]];
11430
- // return vec3.fromValues(this.min[0], this.max[1], this.min[2]);
11431
- } else if (plane.pnVertexFlag === 0x100) {
11432
- return [this.min[0], this.max[1], this.max[2]];
11433
- // return vec3.fromValues(this.min[0], this.max[1], this.max[2]);
11434
- } else if (plane.pnVertexFlag === 0x011) {
11435
- return [this.max[0], this.min[1], this.min[2]];
11436
- // return vec3.fromValues(this.max[0], this.min[1], this.min[2]);
11437
- } else if (plane.pnVertexFlag === 0x010) {
11438
- return [this.max[0], this.min[1], this.max[2]];
11439
- // return vec3.fromValues(this.max[0], this.min[1], this.max[2]);
11440
- } else if (plane.pnVertexFlag === 0x001) {
11441
- return [this.max[0], this.max[1], this.min[2]];
11442
- // return vec3.fromValues(this.max[0], this.max[1], this.min[2]);
11443
- } else {
11444
- return [this.max[0], this.max[1], this.max[2]];
11445
- // return vec3.fromValues(this.max[0], this.max[1], this.max[2]);
11446
- }
11362
+ }
11363
+ function parseDimensionArray(string) {
11364
+ if (isString(string)) {
11365
+ // "1px 2px 3px"
11366
+ return string.split(' ').map(function (segment) {
11367
+ return parseLengthOrPercentage(segment);
11368
+ });
11369
+ } else {
11370
+ // [1, '2px', 3]
11371
+ return string.map(function (segment) {
11372
+ return parseLengthOrPercentage(segment.toString());
11373
+ });
11447
11374
  }
11448
- /**
11449
- * get p-vertex
11450
- * @param plane plane of CullingVolume
11451
- */;
11452
- _proto.getPositiveFarPoint = function getPositiveFarPoint(plane) {
11453
- if (plane.pnVertexFlag === 0x111) {
11454
- return copyVec3([0, 0, 0], this.max);
11455
- // return vec3.copy(vec3.create(), this.max);
11456
- } else if (plane.pnVertexFlag === 0x110) {
11457
- return [this.max[0], this.max[1], this.min[2]];
11458
- // return vec3.fromValues(this.max[0], this.max[1], this.min[2]);
11459
- } else if (plane.pnVertexFlag === 0x101) {
11460
- return [this.max[0], this.min[1], this.max[2]];
11461
- // return vec3.fromValues(this.max[0], this.min[1], this.max[2]);
11462
- } else if (plane.pnVertexFlag === 0x100) {
11463
- return [this.max[0], this.min[1], this.min[2]];
11464
- // return vec3.fromValues(this.max[0], this.min[1], this.min[2]);
11465
- } else if (plane.pnVertexFlag === 0x011) {
11466
- return [this.min[0], this.max[1], this.max[2]];
11467
- // return vec3.fromValues(this.min[0], this.max[1], this.max[2]);
11468
- } else if (plane.pnVertexFlag === 0x010) {
11469
- return [this.min[0], this.max[1], this.min[2]];
11470
- // return vec3.fromValues(this.min[0], this.max[1], this.min[2]);
11471
- } else if (plane.pnVertexFlag === 0x001) {
11472
- return [this.min[0], this.min[1], this.max[2]];
11473
- // return vec3.fromValues(this.min[0], this.min[1], this.max[2]);
11474
- } else {
11475
- return [this.min[0], this.min[1], this.min[2]];
11476
- // return vec3.fromValues(this.min[0], this.min[1], this.min[2]);
11477
- }
11478
- };
11479
- return AABB;
11480
- }();
11481
-
11482
- var Plane = /*#__PURE__*/function () {
11483
- /**
11484
- * lookup table for p-vertex & n-vertex when doing frustum culling
11485
- */
11375
+ }
11376
+ // export function mergeDimensionList(
11377
+ // left: CSSUnitValue[],
11378
+ // right: CSSUnitValue[],
11379
+ // target: IElement | null,
11380
+ // ): [number[], number[], (list: number[]) => string] | undefined {
11381
+ // if (left.length !== right.length) {
11382
+ // return;
11383
+ // }
11384
+ // const unit = left[0].unit;
11385
+ // return [
11386
+ // left.map((l) => l.value),
11387
+ // right.map((l) => l.value),
11388
+ // (values: number[]) => {
11389
+ // return values.map((n) => new CSSUnitValue(n, unit)).join(' ');
11390
+ // },
11391
+ // ];
11392
+ // }
11393
+ function convertPercentUnit(valueWithUnit, vec3Index, target) {
11394
+ if (valueWithUnit.value === 0) {
11395
+ return 0;
11396
+ }
11397
+ if (valueWithUnit.unit === exports.UnitType.kPixels) {
11398
+ return Number(valueWithUnit.value);
11399
+ } else if (valueWithUnit.unit === exports.UnitType.kPercentage && target) {
11400
+ var bounds = target.nodeName === exports.Shape.GROUP ? target.getLocalBounds() :
11401
+ // : target.getGeometryBounds();
11402
+ target.geometry.contentBounds;
11403
+ return valueWithUnit.value / 100 * bounds.halfExtents[vec3Index] * 2;
11404
+ }
11405
+ return 0;
11406
+ }
11486
11407
 
11487
- function Plane(distance, normal) {
11488
- this.distance = void 0;
11489
- this.normal = void 0;
11490
- this.pnVertexFlag = void 0;
11491
- this.distance = distance || 0;
11492
- this.normal = normal || fromValues$2(0, 1, 0);
11493
- this.updatePNVertexFlag();
11408
+ var parseParam = function parseParam(css) {
11409
+ return parseDimension(/deg|rad|grad|turn|px|%/g, css);
11410
+ };
11411
+ var supportedFilters = ['blur', 'brightness', 'drop-shadow', 'contrast', 'grayscale', 'sepia', 'saturate', 'hue-rotate', 'invert'];
11412
+ function parseFilter(filterStr) {
11413
+ if (filterStr === void 0) {
11414
+ filterStr = '';
11494
11415
  }
11495
- var _proto = Plane.prototype;
11496
- _proto.updatePNVertexFlag = function updatePNVertexFlag() {
11497
- this.pnVertexFlag = (Number(this.normal[0] >= 0) << 8) + (Number(this.normal[1] >= 0) << 4) + Number(this.normal[2] >= 0);
11498
- };
11499
- _proto.distanceToPoint = function distanceToPoint(point) {
11500
- return dot(point, this.normal) - this.distance;
11501
- };
11502
- _proto.normalize = function normalize() {
11503
- var invLen = 1 / len(this.normal);
11504
- scale$1(this.normal, this.normal, invLen);
11505
- this.distance *= invLen;
11506
- };
11507
- _proto.intersectsLine = function intersectsLine(start, end, point) {
11508
- var d0 = this.distanceToPoint(start);
11509
- var d1 = this.distanceToPoint(end);
11510
- var t = d0 / (d0 - d1);
11511
- var intersects = t >= 0 && t <= 1;
11512
- if (intersects && point) {
11513
- lerp(point, start, end, t);
11416
+ filterStr = filterStr.toLowerCase().trim();
11417
+ if (filterStr === 'none') {
11418
+ return [];
11419
+ }
11420
+ var filterRegExp = /\s*([\w-]+)\(([^)]*)\)/g;
11421
+ var result = [];
11422
+ var match;
11423
+ var prevLastIndex = 0;
11424
+ while (match = filterRegExp.exec(filterStr)) {
11425
+ if (match.index !== prevLastIndex) {
11426
+ return [];
11514
11427
  }
11515
- return intersects;
11516
- };
11517
- return Plane;
11518
- }();
11519
-
11520
- (function (Mask) {
11521
- Mask[Mask["OUTSIDE"] = 4294967295] = "OUTSIDE";
11522
- Mask[Mask["INSIDE"] = 0] = "INSIDE";
11523
- Mask[Mask["INDETERMINATE"] = 2147483647] = "INDETERMINATE";
11524
- })(exports.Mask || (exports.Mask = {}));
11525
- var Frustum = /*#__PURE__*/function () {
11526
- function Frustum(planes) {
11527
- this.planes = [];
11528
- if (planes) {
11529
- this.planes = planes;
11530
- } else {
11531
- for (var i = 0; i < 6; i++) {
11532
- this.planes.push(new Plane());
11533
- }
11428
+ prevLastIndex = match.index + match[0].length;
11429
+ if (supportedFilters.indexOf(match[1]) > -1) {
11430
+ result.push({
11431
+ name: match[1],
11432
+ params: match[2].split(' ').map(function (p) {
11433
+ return parseParam(p) || parseColor(p);
11434
+ })
11435
+ });
11436
+ }
11437
+ if (filterRegExp.lastIndex === filterStr.length) {
11438
+ return result;
11534
11439
  }
11535
11440
  }
11536
- /**
11537
- * extract 6 planes from projectionMatrix
11538
- * @see http://www8.cs.umu.se/kurser/5DV051/HT12/lab/plane_extraction.pdf
11539
- */
11540
- var _proto = Frustum.prototype;
11541
- _proto.extractFromVPMatrix = function extractFromVPMatrix(projectionMatrix) {
11542
- // @ts-ignore
11543
- var m0 = projectionMatrix[0],
11544
- m1 = projectionMatrix[1],
11545
- m2 = projectionMatrix[2],
11546
- m3 = projectionMatrix[3],
11547
- m4 = projectionMatrix[4],
11548
- m5 = projectionMatrix[5],
11549
- m6 = projectionMatrix[6],
11550
- m7 = projectionMatrix[7],
11551
- m8 = projectionMatrix[8],
11552
- m9 = projectionMatrix[9],
11553
- m10 = projectionMatrix[10],
11554
- m11 = projectionMatrix[11],
11555
- m12 = projectionMatrix[12],
11556
- m13 = projectionMatrix[13],
11557
- m14 = projectionMatrix[14],
11558
- m15 = projectionMatrix[15];
11559
- // right
11560
- set$1(this.planes[0].normal, m3 - m0, m7 - m4, m11 - m8);
11561
- this.planes[0].distance = m15 - m12;
11562
- // left
11563
- set$1(this.planes[1].normal, m3 + m0, m7 + m4, m11 + m8);
11564
- this.planes[1].distance = m15 + m12;
11565
- // bottom
11566
- set$1(this.planes[2].normal, m3 + m1, m7 + m5, m11 + m9);
11567
- this.planes[2].distance = m15 + m13;
11568
- // top
11569
- set$1(this.planes[3].normal, m3 - m1, m7 - m5, m11 - m9);
11570
- this.planes[3].distance = m15 - m13;
11571
- // far
11572
- set$1(this.planes[4].normal, m3 - m2, m7 - m6, m11 - m10);
11573
- this.planes[4].distance = m15 - m14;
11574
- // near
11575
- set$1(this.planes[5].normal, m3 + m2, m7 + m6, m11 + m10);
11576
- this.planes[5].distance = m15 + m14;
11577
- this.planes.forEach(function (plane) {
11578
- plane.normalize();
11579
- plane.updatePNVertexFlag();
11580
- });
11581
- };
11582
- return Frustum;
11583
- }();
11584
-
11585
- var Point = /*#__PURE__*/function () {
11586
- function Point(x, y) {
11587
- if (x === void 0) {
11588
- x = 0;
11589
- }
11590
- if (y === void 0) {
11591
- y = 0;
11592
- }
11593
- this.x = 0;
11594
- this.y = 0;
11595
- this.x = x;
11596
- this.y = y;
11597
- }
11598
- var _proto = Point.prototype;
11599
- _proto.clone = function clone() {
11600
- return new Point(this.x, this.y);
11601
- };
11602
- _proto.copyFrom = function copyFrom(p) {
11603
- this.x = p.x;
11604
- this.y = p.y;
11605
- };
11606
- return Point;
11607
- }();
11608
-
11609
- var Rectangle = /*#__PURE__*/function () {
11610
- function Rectangle(x, y, width, height) {
11611
- this.x = void 0;
11612
- this.y = void 0;
11613
- this.width = void 0;
11614
- this.height = void 0;
11615
- this.left = void 0;
11616
- this.right = void 0;
11617
- this.top = void 0;
11618
- this.bottom = void 0;
11619
- this.x = x;
11620
- this.y = y;
11621
- this.width = width;
11622
- this.height = height;
11623
- this.left = x;
11624
- this.right = x + width;
11625
- this.top = y;
11626
- this.bottom = y + height;
11627
- }
11628
- var _proto = Rectangle.prototype;
11629
- _proto.toJSON = function toJSON() {};
11630
- return Rectangle;
11631
- }();
11441
+ return [];
11442
+ }
11632
11443
 
11633
- function parseDimension(unitRegExp, string) {
11634
- if (isNil(string)) {
11635
- return getOrCreateUnitValue(0, 'px');
11636
- }
11637
- string = ("" + string).trim().toLowerCase();
11638
- if (isFinite(Number(string))) {
11639
- if ('px'.search(unitRegExp) >= 0) {
11640
- return getOrCreateUnitValue(Number(string), 'px');
11641
- } else if ('deg'.search(unitRegExp) >= 0) {
11642
- return getOrCreateUnitValue(Number(string), 'deg');
11643
- }
11644
- }
11645
- var matchedUnits = [];
11646
- string = string.replace(unitRegExp, function (match) {
11647
- matchedUnits.push(match);
11648
- return 'U' + match;
11649
- });
11650
- var taggedUnitRegExp = 'U(' + unitRegExp.source + ')';
11651
- return matchedUnits.map(function (unit) {
11652
- return getOrCreateUnitValue(Number(string.replace(new RegExp('U' + unit, 'g'), '').replace(new RegExp(taggedUnitRegExp, 'g'), '*0')), unit);
11653
- })[0];
11444
+ function numberToString(x) {
11445
+ // scale(0.00000001) -> scale(0)
11446
+ // return x.toFixed(6).replace(/0+$/, '').replace(/\.$/, '');
11447
+ return x.toString();
11654
11448
  }
11655
11449
  /**
11656
- * <length>
11657
- * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/length
11658
- * length with only absolute unit, eg. 1px
11659
- */
11660
- var parseLength = memoize(function (css) {
11661
- return parseDimension(new RegExp('px', 'g'), css);
11662
- });
11663
- /**
11664
- * <percentage>
11665
- * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/percentage
11666
- */
11667
- var parserPercentage = memoize(function (css) {
11668
- return parseDimension(new RegExp('%', 'g'), css);
11669
- });
11670
- /**
11671
- * length with absolute or relative unit,
11672
- * eg. 1px, 0.7em, 50%, calc(100% - 200px);
11450
+ * parse string or number to CSSUnitValue(numeric)
11673
11451
  *
11674
- * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/length-percentage
11452
+ * eg.
11453
+ * * 0 -> CSSUnitValue(0)
11454
+ * * '2' -> CSSUnitValue(2)
11675
11455
  */
11676
- // export const parseLengthOrPercentage = memoize((css: string): CSSUnitValue => {
11677
- // if (isNumber(css) || isFinite(Number(css))) {
11678
- // return getOrCreateUnitValue(Number(css), 'px');
11679
- // }
11680
- // return parseDimension(new RegExp('px|%|em|rem', 'g'), css) as CSSUnitValue;
11681
- // });
11682
- var parseLengthOrPercentage = function parseLengthOrPercentage(css) {
11683
- if (isNumber(css) || isFinite(Number(css))) {
11684
- return getOrCreateUnitValue(Number(css), 'px');
11685
- // return Number(css);
11456
+ var parseNumber = memoize(function (string) {
11457
+ if (typeof string === 'number') {
11458
+ return getOrCreateUnitValue(string);
11459
+ }
11460
+ if (/^\s*[-+]?(\d*\.)?\d+\s*$/.test(string)) {
11461
+ return getOrCreateUnitValue(Number(string));
11462
+ } else {
11463
+ return getOrCreateUnitValue(0);
11686
11464
  }
11687
-
11688
- return parseDimension(new RegExp('px|%|em|rem', 'g'), css);
11689
- };
11690
- var parseAngle = memoize(function (css) {
11691
- return parseDimension(new RegExp('deg|rad|grad|turn', 'g'), css);
11692
11465
  });
11693
11466
  /**
11694
- * merge CSSUnitValue
11695
- *
11696
- * @example
11697
- * 10px + 20px = 30px
11698
- * 10deg + 10rad
11699
- * 10% + 20% = 30%
11467
+ * separate string to array
11468
+ * eg.
11469
+ * * [0.5, 0.5] -> [CSSUnitValue, CSSUnitValue]
11700
11470
  */
11701
- function mergeDimensions(left, right, target, nonNegative, index) {
11702
- if (index === void 0) {
11703
- index = 0;
11704
- }
11705
- var unit = '';
11706
- var leftValue = left.value || 0;
11707
- var rightValue = right.value || 0;
11708
- var canonicalUnit = toCanonicalUnit(left.unit);
11709
- var leftCanonicalUnitValue = left.convertTo(canonicalUnit);
11710
- var rightCanonicalUnitValue = right.convertTo(canonicalUnit);
11711
- if (leftCanonicalUnitValue && rightCanonicalUnitValue) {
11712
- leftValue = leftCanonicalUnitValue.value;
11713
- rightValue = rightCanonicalUnitValue.value;
11714
- unit = unitTypeToString(left.unit);
11471
+ var parseNumberList = memoize(function (string) {
11472
+ if (isString(string)) {
11473
+ return string.split(' ').map(parseNumber);
11715
11474
  } else {
11716
- // format '%' to 'px'
11717
- if (CSSUnitValue.isLength(left.unit) || CSSUnitValue.isLength(right.unit)) {
11718
- leftValue = convertPercentUnit(left, index, target);
11719
- rightValue = convertPercentUnit(right, index, target);
11720
- unit = 'px';
11721
- }
11475
+ return string.map(parseNumber);
11722
11476
  }
11723
- // // format 'rad' 'turn' to 'deg'
11724
- // if (CSSUnitValue.isAngle(left.unit) || CSSUnitValue.isAngle(right.unit)) {
11725
- // leftValue = convertAngleUnit(left);
11726
- // rightValue = convertAngleUnit(right);
11727
- // unit = 'deg';
11728
- // }
11729
- return [leftValue, rightValue, function (value) {
11730
- if (nonNegative) {
11731
- value = Math.max(value, 0);
11732
- }
11733
- return value + unit;
11734
- }];
11477
+ });
11478
+ function mergeNumbers(left, right) {
11479
+ return [left, right, numberToString];
11735
11480
  }
11736
- function convertAngleUnit(value) {
11737
- var deg = 0;
11738
- if (value.unit === exports.UnitType.kDegrees) {
11739
- deg = value.value;
11740
- } else if (value.unit === exports.UnitType.kRadians) {
11741
- deg = rad2deg(Number(value.value));
11742
- } else if (value.unit === exports.UnitType.kTurns) {
11743
- deg = turn2deg(Number(value.value));
11744
- }
11745
- return deg;
11481
+ function clampedMergeNumbers(min, max) {
11482
+ return function (left, right) {
11483
+ return [left, right, function (x) {
11484
+ return numberToString(clamp(x, min, max));
11485
+ }];
11486
+ };
11746
11487
  }
11747
- function parseDimensionArrayFormat(string, size) {
11748
- var parsed;
11749
- if (Array.isArray(string)) {
11750
- // [1, '2px', 3]
11751
- parsed = string.map(function (segment) {
11752
- return Number(segment);
11753
- });
11754
- } else if (isString(string)) {
11755
- parsed = string.split(' ').map(function (segment) {
11756
- return Number(segment);
11757
- });
11758
- } else if (isNumber(string)) {
11759
- parsed = [string];
11760
- }
11761
- if (size === 2) {
11762
- if (parsed.length === 1) {
11763
- return [parsed[0], parsed[0]];
11764
- } else {
11765
- return [parsed[0], parsed[1]];
11766
- }
11767
- } else {
11768
- if (parsed.length === 1) {
11769
- return [parsed[0], parsed[0], parsed[0], parsed[0]];
11770
- } else if (parsed.length === 2) {
11771
- return [parsed[0], parsed[1], parsed[0], parsed[1]];
11772
- } else if (parsed.length === 3) {
11773
- return [parsed[0], parsed[1], parsed[2], parsed[1]];
11774
- } else {
11775
- return [parsed[0], parsed[1], parsed[2], parsed[3]];
11776
- }
11777
- }
11778
- }
11779
- function parseDimensionArray(string) {
11780
- if (isString(string)) {
11781
- // "1px 2px 3px"
11782
- return string.split(' ').map(function (segment) {
11783
- return parseLengthOrPercentage(segment);
11784
- });
11785
- } else {
11786
- // [1, '2px', 3]
11787
- return string.map(function (segment) {
11788
- return parseLengthOrPercentage(segment.toString());
11789
- });
11790
- }
11791
- }
11792
- // export function mergeDimensionList(
11793
- // left: CSSUnitValue[],
11794
- // right: CSSUnitValue[],
11795
- // target: IElement | null,
11796
- // ): [number[], number[], (list: number[]) => string] | undefined {
11797
- // if (left.length !== right.length) {
11798
- // return;
11799
- // }
11800
- // const unit = left[0].unit;
11801
- // return [
11802
- // left.map((l) => l.value),
11803
- // right.map((l) => l.value),
11804
- // (values: number[]) => {
11805
- // return values.map((n) => new CSSUnitValue(n, unit)).join(' ');
11806
- // },
11807
- // ];
11808
- // }
11809
- function convertPercentUnit(valueWithUnit, vec3Index, target) {
11810
- if (valueWithUnit.unit === exports.UnitType.kPixels) {
11811
- return Number(valueWithUnit.value);
11812
- } else if (valueWithUnit.unit === exports.UnitType.kPercentage && target) {
11813
- var bounds = target.nodeName === exports.Shape.GROUP ? target.getLocalBounds() :
11814
- // : target.getGeometryBounds();
11815
- target.geometry.contentBounds;
11816
- var size = 0;
11817
- if (!AABB.isEmpty(bounds)) {
11818
- size = bounds.halfExtents[vec3Index] * 2;
11819
- }
11820
- return Number(valueWithUnit.value) / 100 * size;
11821
- }
11822
- return 0;
11823
- }
11824
-
11825
- var parseParam = function parseParam(css) {
11826
- return parseDimension(/deg|rad|grad|turn|px|%/g, css);
11827
- };
11828
- var supportedFilters = ['blur', 'brightness', 'drop-shadow', 'contrast', 'grayscale', 'sepia', 'saturate', 'hue-rotate', 'invert'];
11829
- function parseFilter(filterStr) {
11830
- if (filterStr === void 0) {
11831
- filterStr = '';
11832
- }
11833
- filterStr = filterStr.toLowerCase().trim();
11834
- if (filterStr === 'none') {
11835
- return [];
11836
- }
11837
- var filterRegExp = /\s*([\w-]+)\(([^)]*)\)/g;
11838
- var result = [];
11839
- var match;
11840
- var prevLastIndex = 0;
11841
- while (match = filterRegExp.exec(filterStr)) {
11842
- if (match.index !== prevLastIndex) {
11843
- return [];
11844
- }
11845
- prevLastIndex = match.index + match[0].length;
11846
- if (supportedFilters.indexOf(match[1]) > -1) {
11847
- result.push({
11848
- name: match[1],
11849
- params: match[2].split(' ').map(function (p) {
11850
- return parseParam(p) || parseColor(p);
11851
- })
11852
- });
11853
- }
11854
- if (filterRegExp.lastIndex === filterStr.length) {
11855
- return result;
11856
- }
11857
- }
11858
- return [];
11859
- }
11860
-
11861
- function numberToString(x) {
11862
- // scale(0.00000001) -> scale(0)
11863
- // return x.toFixed(6).replace(/0+$/, '').replace(/\.$/, '');
11864
- return x.toString();
11865
- }
11866
- /**
11867
- * parse string or number to CSSUnitValue(numeric)
11868
- *
11869
- * eg.
11870
- * * 0 -> CSSUnitValue(0)
11871
- * * '2' -> CSSUnitValue(2)
11872
- */
11873
- var parseNumber = memoize(function (string) {
11874
- if (typeof string === 'number') {
11875
- return getOrCreateUnitValue(string);
11876
- }
11877
- if (/^\s*[-+]?(\d*\.)?\d+\s*$/.test(string)) {
11878
- return getOrCreateUnitValue(Number(string));
11879
- } else {
11880
- return getOrCreateUnitValue(0);
11881
- }
11882
- });
11883
- /**
11884
- * separate string to array
11885
- * eg.
11886
- * * [0.5, 0.5] -> [CSSUnitValue, CSSUnitValue]
11887
- */
11888
- var parseNumberList = memoize(function (string) {
11889
- if (isString(string)) {
11890
- return string.split(' ').map(parseNumber);
11891
- } else {
11892
- return string.map(parseNumber);
11893
- }
11894
- });
11895
- function mergeNumbers(left, right) {
11896
- return [left, right, numberToString];
11897
- }
11898
- function clampedMergeNumbers(min, max) {
11899
- return function (left, right) {
11900
- return [left, right, function (x) {
11901
- return numberToString(clamp(x, min, max));
11902
- }];
11903
- };
11904
- }
11905
- function mergeNumberLists(left, right) {
11906
- if (left.length !== right.length) {
11907
- return;
11488
+ function mergeNumberLists(left, right) {
11489
+ if (left.length !== right.length) {
11490
+ return;
11908
11491
  }
11909
11492
  return [left, right, function (numberList) {
11910
11493
  return numberList;
@@ -12048,6 +11631,11 @@
12048
11631
  segments: segments
12049
11632
  };
12050
11633
  }
11634
+ function mergePoints(left, right) {
11635
+ return [left.points, right.points, function (points) {
11636
+ return points;
11637
+ }];
11638
+ }
12051
11639
 
12052
11640
  var _ = null;
12053
11641
  function cast(pattern) {
@@ -12853,74 +12441,484 @@
12853
12441
  if (newMarker instanceof CSSKeywordValue) {
12854
12442
  newMarker = null;
12855
12443
  }
12856
- var cloned = (_newMarker = newMarker) === null || _newMarker === void 0 ? void 0 : _newMarker.cloneNode(true);
12857
- if (cloned) {
12858
- // FIXME: SVG should not inherit parent's style, add a flag here
12859
- cloned.style.isMarker = true;
12444
+ var cloned = (_newMarker = newMarker) === null || _newMarker === void 0 ? void 0 : _newMarker.cloneNode(true);
12445
+ if (cloned) {
12446
+ // FIXME: SVG should not inherit parent's style, add a flag here
12447
+ cloned.style.isMarker = true;
12448
+ }
12449
+ return cloned;
12450
+ };
12451
+ return CSSPropertyMarker;
12452
+ }();
12453
+
12454
+ var CSSPropertyNumber = /*#__PURE__*/function () {
12455
+ function CSSPropertyNumber() {
12456
+ this.mixer = mergeNumbers;
12457
+ this.parser = parseNumber;
12458
+ this.parserWithCSSDisabled = null;
12459
+ }
12460
+ var _proto = CSSPropertyNumber.prototype;
12461
+ _proto.calculator = function calculator(name, oldParsed, computed) {
12462
+ return computed.value;
12463
+ };
12464
+ return CSSPropertyNumber;
12465
+ }();
12466
+
12467
+ var CSSPropertyOffsetDistance = /*#__PURE__*/function () {
12468
+ function CSSPropertyOffsetDistance() {
12469
+ this.parser = parseNumber;
12470
+ this.parserWithCSSDisabled = null;
12471
+ this.mixer = clampedMergeNumbers(0, 1);
12472
+ }
12473
+ var _proto = CSSPropertyOffsetDistance.prototype;
12474
+ _proto.calculator = function calculator(name, oldParsed, computed) {
12475
+ return computed.value;
12476
+ };
12477
+ _proto.postProcessor = function postProcessor(object) {
12478
+ var _object$parsedStyle = object.parsedStyle,
12479
+ offsetPath = _object$parsedStyle.offsetPath,
12480
+ offsetDistance = _object$parsedStyle.offsetDistance;
12481
+ if (!offsetPath) {
12482
+ return;
12483
+ }
12484
+ var nodeName = offsetPath.nodeName;
12485
+ if (nodeName === exports.Shape.LINE || nodeName === exports.Shape.PATH || nodeName === exports.Shape.POLYLINE) {
12486
+ // set position in world space
12487
+ var point = offsetPath.getPoint(offsetDistance);
12488
+ if (point) {
12489
+ object.parsedStyle.defX = point.x;
12490
+ object.parsedStyle.defY = point.y;
12491
+ object.setLocalPosition(point.x, point.y);
12492
+ }
12493
+ }
12494
+ };
12495
+ return CSSPropertyOffsetDistance;
12496
+ }();
12497
+
12498
+ /**
12499
+ * opacity
12500
+ */
12501
+ var CSSPropertyOpacity = /*#__PURE__*/function () {
12502
+ function CSSPropertyOpacity() {
12503
+ this.parser = parseNumber;
12504
+ this.parserWithCSSDisabled = null;
12505
+ this.mixer = clampedMergeNumbers(0, 1);
12506
+ }
12507
+ var _proto = CSSPropertyOpacity.prototype;
12508
+ _proto.calculator = function calculator(name, oldParsed, computed) {
12509
+ return computed.value;
12510
+ };
12511
+ return CSSPropertyOpacity;
12512
+ }();
12513
+
12514
+ /**
12515
+ * Axis-Aligned Bounding Box
12516
+ * 为了便于后续 Frustum Culling,通过查找表定义 p-vertex 和 n-vertex
12517
+ * @see https://github.com/antvis/GWebGPUEngine/issues/3
12518
+ */
12519
+ var AABB = /*#__PURE__*/function () {
12520
+ function AABB() {
12521
+ this.center = [0, 0, 0];
12522
+ this.halfExtents = [0, 0, 0];
12523
+ this.min = [0, 0, 0];
12524
+ this.max = [0, 0, 0];
12525
+ }
12526
+ AABB.isEmpty = function isEmpty(aabb) {
12527
+ return !aabb || aabb.halfExtents[0] === 0 && aabb.halfExtents[1] === 0 && aabb.halfExtents[2] === 0;
12528
+ };
12529
+ var _proto = AABB.prototype;
12530
+ // center: vec3 = vec3.create();
12531
+ // halfExtents: vec3 = vec3.create();
12532
+ // min: vec3 = vec3.create();
12533
+ // max: vec3 = vec3.create();
12534
+ _proto.update = function update(center, halfExtents) {
12535
+ copyVec3(this.center, center);
12536
+ copyVec3(this.halfExtents, halfExtents);
12537
+ subVec3(this.min, this.center, this.halfExtents);
12538
+ addVec3(this.max, this.center, this.halfExtents);
12539
+ // vec3.copy(this.center, center);
12540
+ // vec3.copy(this.halfExtents, halfExtents);
12541
+ // vec3.sub(this.min, this.center, this.halfExtents);
12542
+ // vec3.add(this.max, this.center, this.halfExtents);
12543
+ };
12544
+ _proto.setMinMax = function setMinMax(min, max) {
12545
+ // vec3.add(this.center, max, min);
12546
+ // vec3.scale(this.center, this.center, 0.5);
12547
+ // vec3.sub(this.halfExtents, max, min);
12548
+ // vec3.scale(this.halfExtents, this.halfExtents, 0.5);
12549
+ // vec3.copy(this.min, min);
12550
+ // vec3.copy(this.max, max);
12551
+ addVec3(this.center, max, min);
12552
+ scaleVec3(this.center, this.center, 0.5);
12553
+ subVec3(this.halfExtents, max, min);
12554
+ scaleVec3(this.halfExtents, this.halfExtents, 0.5);
12555
+ copyVec3(this.min, min);
12556
+ copyVec3(this.max, max);
12557
+ };
12558
+ _proto.getMin = function getMin() {
12559
+ return this.min;
12560
+ };
12561
+ _proto.getMax = function getMax() {
12562
+ return this.max;
12563
+ };
12564
+ _proto.add = function add(aabb) {
12565
+ if (AABB.isEmpty(aabb)) {
12566
+ return;
12567
+ }
12568
+ if (AABB.isEmpty(this)) {
12569
+ this.setMinMax(aabb.getMin(), aabb.getMax());
12570
+ return;
12571
+ }
12572
+ var tc = this.center;
12573
+ var tcx = tc[0];
12574
+ var tcy = tc[1];
12575
+ var tcz = tc[2];
12576
+ var th = this.halfExtents;
12577
+ var thx = th[0];
12578
+ var thy = th[1];
12579
+ var thz = th[2];
12580
+ var tminx = tcx - thx;
12581
+ var tmaxx = tcx + thx;
12582
+ var tminy = tcy - thy;
12583
+ var tmaxy = tcy + thy;
12584
+ var tminz = tcz - thz;
12585
+ var tmaxz = tcz + thz;
12586
+ var oc = aabb.center;
12587
+ var ocx = oc[0];
12588
+ var ocy = oc[1];
12589
+ var ocz = oc[2];
12590
+ var oh = aabb.halfExtents;
12591
+ var ohx = oh[0];
12592
+ var ohy = oh[1];
12593
+ var ohz = oh[2];
12594
+ var ominx = ocx - ohx;
12595
+ var omaxx = ocx + ohx;
12596
+ var ominy = ocy - ohy;
12597
+ var omaxy = ocy + ohy;
12598
+ var ominz = ocz - ohz;
12599
+ var omaxz = ocz + ohz;
12600
+ if (ominx < tminx) {
12601
+ tminx = ominx;
12602
+ }
12603
+ if (omaxx > tmaxx) {
12604
+ tmaxx = omaxx;
12605
+ }
12606
+ if (ominy < tminy) {
12607
+ tminy = ominy;
12608
+ }
12609
+ if (omaxy > tmaxy) {
12610
+ tmaxy = omaxy;
12611
+ }
12612
+ if (ominz < tminz) {
12613
+ tminz = ominz;
12614
+ }
12615
+ if (omaxz > tmaxz) {
12616
+ tmaxz = omaxz;
12617
+ }
12618
+ tc[0] = (tminx + tmaxx) * 0.5;
12619
+ tc[1] = (tminy + tmaxy) * 0.5;
12620
+ tc[2] = (tminz + tmaxz) * 0.5;
12621
+ th[0] = (tmaxx - tminx) * 0.5;
12622
+ th[1] = (tmaxy - tminy) * 0.5;
12623
+ th[2] = (tmaxz - tminz) * 0.5;
12624
+ this.min[0] = tminx;
12625
+ this.min[1] = tminy;
12626
+ this.min[2] = tminz;
12627
+ this.max[0] = tmaxx;
12628
+ this.max[1] = tmaxy;
12629
+ this.max[2] = tmaxz;
12630
+ };
12631
+ _proto.setFromTransformedAABB = function setFromTransformedAABB(aabb, m) {
12632
+ var bc = this.center;
12633
+ var br = this.halfExtents;
12634
+ var ac = aabb.center;
12635
+ var ar = aabb.halfExtents;
12636
+ var mx0 = m[0];
12637
+ var mx1 = m[4];
12638
+ var mx2 = m[8];
12639
+ var my0 = m[1];
12640
+ var my1 = m[5];
12641
+ var my2 = m[9];
12642
+ var mz0 = m[2];
12643
+ var mz1 = m[6];
12644
+ var mz2 = m[10];
12645
+ var mx0a = Math.abs(mx0);
12646
+ var mx1a = Math.abs(mx1);
12647
+ var mx2a = Math.abs(mx2);
12648
+ var my0a = Math.abs(my0);
12649
+ var my1a = Math.abs(my1);
12650
+ var my2a = Math.abs(my2);
12651
+ var mz0a = Math.abs(mz0);
12652
+ var mz1a = Math.abs(mz1);
12653
+ var mz2a = Math.abs(mz2);
12654
+ bc[0] = m[12] + mx0 * ac[0] + mx1 * ac[1] + mx2 * ac[2];
12655
+ bc[1] = m[13] + my0 * ac[0] + my1 * ac[1] + my2 * ac[2];
12656
+ bc[2] = m[14] + mz0 * ac[0] + mz1 * ac[1] + mz2 * ac[2];
12657
+ // vec3.set(
12658
+ // bc,
12659
+ // m[12] + mx0 * ac[0] + mx1 * ac[1] + mx2 * ac[2],
12660
+ // m[13] + my0 * ac[0] + my1 * ac[1] + my2 * ac[2],
12661
+ // m[14] + mz0 * ac[0] + mz1 * ac[1] + mz2 * ac[2],
12662
+ // );
12663
+ br[0] = mx0a * ar[0] + mx1a * ar[1] + mx2a * ar[2];
12664
+ br[1] = my0a * ar[0] + my1a * ar[1] + my2a * ar[2];
12665
+ br[2] = mz0a * ar[0] + mz1a * ar[1] + mz2a * ar[2];
12666
+ // vec3.set(
12667
+ // br,
12668
+ // mx0a * ar[0] + mx1a * ar[1] + mx2a * ar[2],
12669
+ // my0a * ar[0] + my1a * ar[1] + my2a * ar[2],
12670
+ // mz0a * ar[0] + mz1a * ar[1] + mz2a * ar[2],
12671
+ // );
12672
+ // this.min = vec3.sub(this.min, bc, br);
12673
+ // this.max = vec3.add(this.max, bc, br);
12674
+ subVec3(this.min, bc, br);
12675
+ addVec3(this.max, bc, br);
12676
+ };
12677
+ _proto.intersects = function intersects(aabb) {
12678
+ var aMax = this.getMax();
12679
+ var aMin = this.getMin();
12680
+ var bMax = aabb.getMax();
12681
+ var bMin = aabb.getMin();
12682
+ return aMin[0] <= bMax[0] && aMax[0] >= bMin[0] && aMin[1] <= bMax[1] && aMax[1] >= bMin[1] && aMin[2] <= bMax[2] && aMax[2] >= bMin[2];
12683
+ };
12684
+ _proto.intersection = function intersection(aabb) {
12685
+ if (!this.intersects(aabb)) {
12686
+ return null;
12687
+ }
12688
+ var intersection = new AABB();
12689
+ // const min = vec3.max(vec3.create(), this.getMin(), aabb.getMin());
12690
+ // const max = vec3.min(vec3.create(), this.getMax(), aabb.getMax());
12691
+ var min = maxVec3([0, 0, 0], this.getMin(), aabb.getMin());
12692
+ var max = minVec3([0, 0, 0], this.getMax(), aabb.getMax());
12693
+ intersection.setMinMax(min, max);
12694
+ return intersection;
12695
+ }
12696
+ // containsPoint(point: vec3) {
12697
+ // const min = this.getMin();
12698
+ // const max = this.getMax();
12699
+ // return !(
12700
+ // point[0] < min[0] ||
12701
+ // point[0] > max[0] ||
12702
+ // point[1] < min[1] ||
12703
+ // point[1] > max[1] ||
12704
+ // point[2] < min[2] ||
12705
+ // point[2] > max[2]
12706
+ // );
12707
+ // }
12708
+ /**
12709
+ * get n-vertex
12710
+ * @param plane plane of CullingVolume
12711
+ */;
12712
+ _proto.getNegativeFarPoint = function getNegativeFarPoint(plane) {
12713
+ if (plane.pnVertexFlag === 0x111) {
12714
+ return copyVec3([0, 0, 0], this.min);
12715
+ // return vec3.copy(vec3.create(), this.min);
12716
+ } else if (plane.pnVertexFlag === 0x110) {
12717
+ return [this.min[0], this.min[1], this.max[2]];
12718
+ // return vec3.fromValues(this.min[0], this.min[1], this.max[2]);
12719
+ } else if (plane.pnVertexFlag === 0x101) {
12720
+ return [this.min[0], this.max[1], this.min[2]];
12721
+ // return vec3.fromValues(this.min[0], this.max[1], this.min[2]);
12722
+ } else if (plane.pnVertexFlag === 0x100) {
12723
+ return [this.min[0], this.max[1], this.max[2]];
12724
+ // return vec3.fromValues(this.min[0], this.max[1], this.max[2]);
12725
+ } else if (plane.pnVertexFlag === 0x011) {
12726
+ return [this.max[0], this.min[1], this.min[2]];
12727
+ // return vec3.fromValues(this.max[0], this.min[1], this.min[2]);
12728
+ } else if (plane.pnVertexFlag === 0x010) {
12729
+ return [this.max[0], this.min[1], this.max[2]];
12730
+ // return vec3.fromValues(this.max[0], this.min[1], this.max[2]);
12731
+ } else if (plane.pnVertexFlag === 0x001) {
12732
+ return [this.max[0], this.max[1], this.min[2]];
12733
+ // return vec3.fromValues(this.max[0], this.max[1], this.min[2]);
12734
+ } else {
12735
+ return [this.max[0], this.max[1], this.max[2]];
12736
+ // return vec3.fromValues(this.max[0], this.max[1], this.max[2]);
12737
+ }
12738
+ }
12739
+ /**
12740
+ * get p-vertex
12741
+ * @param plane plane of CullingVolume
12742
+ */;
12743
+ _proto.getPositiveFarPoint = function getPositiveFarPoint(plane) {
12744
+ if (plane.pnVertexFlag === 0x111) {
12745
+ return copyVec3([0, 0, 0], this.max);
12746
+ // return vec3.copy(vec3.create(), this.max);
12747
+ } else if (plane.pnVertexFlag === 0x110) {
12748
+ return [this.max[0], this.max[1], this.min[2]];
12749
+ // return vec3.fromValues(this.max[0], this.max[1], this.min[2]);
12750
+ } else if (plane.pnVertexFlag === 0x101) {
12751
+ return [this.max[0], this.min[1], this.max[2]];
12752
+ // return vec3.fromValues(this.max[0], this.min[1], this.max[2]);
12753
+ } else if (plane.pnVertexFlag === 0x100) {
12754
+ return [this.max[0], this.min[1], this.min[2]];
12755
+ // return vec3.fromValues(this.max[0], this.min[1], this.min[2]);
12756
+ } else if (plane.pnVertexFlag === 0x011) {
12757
+ return [this.min[0], this.max[1], this.max[2]];
12758
+ // return vec3.fromValues(this.min[0], this.max[1], this.max[2]);
12759
+ } else if (plane.pnVertexFlag === 0x010) {
12760
+ return [this.min[0], this.max[1], this.min[2]];
12761
+ // return vec3.fromValues(this.min[0], this.max[1], this.min[2]);
12762
+ } else if (plane.pnVertexFlag === 0x001) {
12763
+ return [this.min[0], this.min[1], this.max[2]];
12764
+ // return vec3.fromValues(this.min[0], this.min[1], this.max[2]);
12765
+ } else {
12766
+ return [this.min[0], this.min[1], this.min[2]];
12767
+ // return vec3.fromValues(this.min[0], this.min[1], this.min[2]);
12860
12768
  }
12861
- return cloned;
12862
12769
  };
12863
- return CSSPropertyMarker;
12770
+ return AABB;
12864
12771
  }();
12865
12772
 
12866
- var CSSPropertyNumber = /*#__PURE__*/function () {
12867
- function CSSPropertyNumber() {
12868
- this.mixer = mergeNumbers;
12869
- this.parser = parseNumber;
12870
- this.parserWithCSSDisabled = null;
12773
+ var Plane = /*#__PURE__*/function () {
12774
+ /**
12775
+ * lookup table for p-vertex & n-vertex when doing frustum culling
12776
+ */
12777
+
12778
+ function Plane(distance, normal) {
12779
+ this.distance = void 0;
12780
+ this.normal = void 0;
12781
+ this.pnVertexFlag = void 0;
12782
+ this.distance = distance || 0;
12783
+ this.normal = normal || fromValues$2(0, 1, 0);
12784
+ this.updatePNVertexFlag();
12871
12785
  }
12872
- var _proto = CSSPropertyNumber.prototype;
12873
- _proto.calculator = function calculator(name, oldParsed, computed) {
12874
- return computed.value;
12786
+ var _proto = Plane.prototype;
12787
+ _proto.updatePNVertexFlag = function updatePNVertexFlag() {
12788
+ this.pnVertexFlag = (Number(this.normal[0] >= 0) << 8) + (Number(this.normal[1] >= 0) << 4) + Number(this.normal[2] >= 0);
12875
12789
  };
12876
- return CSSPropertyNumber;
12790
+ _proto.distanceToPoint = function distanceToPoint(point) {
12791
+ return dot(point, this.normal) - this.distance;
12792
+ };
12793
+ _proto.normalize = function normalize() {
12794
+ var invLen = 1 / len(this.normal);
12795
+ scale$1(this.normal, this.normal, invLen);
12796
+ this.distance *= invLen;
12797
+ };
12798
+ _proto.intersectsLine = function intersectsLine(start, end, point) {
12799
+ var d0 = this.distanceToPoint(start);
12800
+ var d1 = this.distanceToPoint(end);
12801
+ var t = d0 / (d0 - d1);
12802
+ var intersects = t >= 0 && t <= 1;
12803
+ if (intersects && point) {
12804
+ lerp(point, start, end, t);
12805
+ }
12806
+ return intersects;
12807
+ };
12808
+ return Plane;
12877
12809
  }();
12878
12810
 
12879
- var CSSPropertyOffsetDistance = /*#__PURE__*/function () {
12880
- function CSSPropertyOffsetDistance() {
12881
- this.parser = parseNumber;
12882
- this.parserWithCSSDisabled = null;
12883
- this.mixer = clampedMergeNumbers(0, 1);
12811
+ (function (Mask) {
12812
+ Mask[Mask["OUTSIDE"] = 4294967295] = "OUTSIDE";
12813
+ Mask[Mask["INSIDE"] = 0] = "INSIDE";
12814
+ Mask[Mask["INDETERMINATE"] = 2147483647] = "INDETERMINATE";
12815
+ })(exports.Mask || (exports.Mask = {}));
12816
+ var Frustum = /*#__PURE__*/function () {
12817
+ function Frustum(planes) {
12818
+ this.planes = [];
12819
+ if (planes) {
12820
+ this.planes = planes;
12821
+ } else {
12822
+ for (var i = 0; i < 6; i++) {
12823
+ this.planes.push(new Plane());
12824
+ }
12825
+ }
12884
12826
  }
12885
- var _proto = CSSPropertyOffsetDistance.prototype;
12886
- _proto.calculator = function calculator(name, oldParsed, computed) {
12887
- return computed.value;
12827
+ /**
12828
+ * extract 6 planes from projectionMatrix
12829
+ * @see http://www8.cs.umu.se/kurser/5DV051/HT12/lab/plane_extraction.pdf
12830
+ */
12831
+ var _proto = Frustum.prototype;
12832
+ _proto.extractFromVPMatrix = function extractFromVPMatrix(projectionMatrix) {
12833
+ // @ts-ignore
12834
+ var m0 = projectionMatrix[0],
12835
+ m1 = projectionMatrix[1],
12836
+ m2 = projectionMatrix[2],
12837
+ m3 = projectionMatrix[3],
12838
+ m4 = projectionMatrix[4],
12839
+ m5 = projectionMatrix[5],
12840
+ m6 = projectionMatrix[6],
12841
+ m7 = projectionMatrix[7],
12842
+ m8 = projectionMatrix[8],
12843
+ m9 = projectionMatrix[9],
12844
+ m10 = projectionMatrix[10],
12845
+ m11 = projectionMatrix[11],
12846
+ m12 = projectionMatrix[12],
12847
+ m13 = projectionMatrix[13],
12848
+ m14 = projectionMatrix[14],
12849
+ m15 = projectionMatrix[15];
12850
+ // right
12851
+ set$1(this.planes[0].normal, m3 - m0, m7 - m4, m11 - m8);
12852
+ this.planes[0].distance = m15 - m12;
12853
+ // left
12854
+ set$1(this.planes[1].normal, m3 + m0, m7 + m4, m11 + m8);
12855
+ this.planes[1].distance = m15 + m12;
12856
+ // bottom
12857
+ set$1(this.planes[2].normal, m3 + m1, m7 + m5, m11 + m9);
12858
+ this.planes[2].distance = m15 + m13;
12859
+ // top
12860
+ set$1(this.planes[3].normal, m3 - m1, m7 - m5, m11 - m9);
12861
+ this.planes[3].distance = m15 - m13;
12862
+ // far
12863
+ set$1(this.planes[4].normal, m3 - m2, m7 - m6, m11 - m10);
12864
+ this.planes[4].distance = m15 - m14;
12865
+ // near
12866
+ set$1(this.planes[5].normal, m3 + m2, m7 + m6, m11 + m10);
12867
+ this.planes[5].distance = m15 + m14;
12868
+ this.planes.forEach(function (plane) {
12869
+ plane.normalize();
12870
+ plane.updatePNVertexFlag();
12871
+ });
12888
12872
  };
12889
- _proto.postProcessor = function postProcessor(object) {
12890
- var _object$parsedStyle = object.parsedStyle,
12891
- offsetPath = _object$parsedStyle.offsetPath,
12892
- offsetDistance = _object$parsedStyle.offsetDistance;
12893
- if (!offsetPath) {
12894
- return;
12873
+ return Frustum;
12874
+ }();
12875
+
12876
+ var Point = /*#__PURE__*/function () {
12877
+ function Point(x, y) {
12878
+ if (x === void 0) {
12879
+ x = 0;
12895
12880
  }
12896
- var nodeName = offsetPath.nodeName;
12897
- if (nodeName === exports.Shape.LINE || nodeName === exports.Shape.PATH || nodeName === exports.Shape.POLYLINE) {
12898
- // set position in world space
12899
- var point = offsetPath.getPoint(offsetDistance);
12900
- if (point) {
12901
- object.parsedStyle.defX = point.x;
12902
- object.parsedStyle.defY = point.y;
12903
- object.setLocalPosition(point.x, point.y);
12904
- }
12881
+ if (y === void 0) {
12882
+ y = 0;
12905
12883
  }
12884
+ this.x = 0;
12885
+ this.y = 0;
12886
+ this.x = x;
12887
+ this.y = y;
12888
+ }
12889
+ var _proto = Point.prototype;
12890
+ _proto.clone = function clone() {
12891
+ return new Point(this.x, this.y);
12906
12892
  };
12907
- return CSSPropertyOffsetDistance;
12893
+ _proto.copyFrom = function copyFrom(p) {
12894
+ this.x = p.x;
12895
+ this.y = p.y;
12896
+ };
12897
+ return Point;
12908
12898
  }();
12909
12899
 
12910
- /**
12911
- * opacity
12912
- */
12913
- var CSSPropertyOpacity = /*#__PURE__*/function () {
12914
- function CSSPropertyOpacity() {
12915
- this.parser = parseNumber;
12916
- this.parserWithCSSDisabled = null;
12917
- this.mixer = clampedMergeNumbers(0, 1);
12900
+ var Rectangle = /*#__PURE__*/function () {
12901
+ function Rectangle(x, y, width, height) {
12902
+ this.x = void 0;
12903
+ this.y = void 0;
12904
+ this.width = void 0;
12905
+ this.height = void 0;
12906
+ this.left = void 0;
12907
+ this.right = void 0;
12908
+ this.top = void 0;
12909
+ this.bottom = void 0;
12910
+ this.x = x;
12911
+ this.y = y;
12912
+ this.width = width;
12913
+ this.height = height;
12914
+ this.left = x;
12915
+ this.right = x + width;
12916
+ this.top = y;
12917
+ this.bottom = y + height;
12918
12918
  }
12919
- var _proto = CSSPropertyOpacity.prototype;
12920
- _proto.calculator = function calculator(name, oldParsed, computed) {
12921
- return computed.value;
12922
- };
12923
- return CSSPropertyOpacity;
12919
+ var _proto = Rectangle.prototype;
12920
+ _proto.toJSON = function toJSON() {};
12921
+ return Rectangle;
12924
12922
  }();
12925
12923
 
12926
12924
  var CSSPropertyPath = /*#__PURE__*/function () {
@@ -12965,6 +12963,7 @@
12965
12963
  var CSSPropertyPoints = /*#__PURE__*/function () {
12966
12964
  function CSSPropertyPoints() {
12967
12965
  this.parser = parsePoints;
12966
+ this.mixer = mergePoints;
12968
12967
  }
12969
12968
  var _proto = CSSPropertyPoints.prototype;
12970
12969
  /**
@@ -14601,12 +14600,12 @@
14601
14600
  localPosition: [0, 0, 0],
14602
14601
  localRotation: [0, 0, 0, 1],
14603
14602
  localScale: [1, 1, 1],
14604
- localTransform: create$1(),
14603
+ localTransform: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],
14605
14604
  localSkew: [0, 0],
14606
14605
  position: [0, 0, 0],
14607
14606
  rotation: [0, 0, 0, 1],
14608
14607
  scaling: [1, 1, 1],
14609
- worldTransform: create$1(),
14608
+ worldTransform: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],
14610
14609
  origin: [0, 0, 0]
14611
14610
  };
14612
14611
  _this.sortable = {
@@ -14616,7 +14615,6 @@
14616
14615
  renderOrder: 0
14617
14616
  };
14618
14617
  _this.geometry = {
14619
- dirty: false,
14620
14618
  contentBounds: undefined,
14621
14619
  renderBounds: undefined
14622
14620
  };
@@ -15427,6 +15425,7 @@
15427
15425
  }
15428
15426
  // start to process attributes
15429
15427
  _this.initAttributes(_this.config.style);
15428
+ var Proxy = runtime.globalThis.Proxy ? runtime.globalThis.Proxy : function () {};
15430
15429
  _this.dataset = new Proxy({}, {
15431
15430
  get: function get(target, name) {
15432
15431
  var formattedName = "" + DATASET_PREFIX + kebabize(name);
@@ -16116,7 +16115,7 @@
16116
16115
  }, style) : _extends({}, style),
16117
16116
  initialParsedStyle: {
16118
16117
  anchor: [0.5, 0.5],
16119
- transformOrigin: runtime.enableCSSParsing ? null : [getOrCreateUnitValue(50, '%'), getOrCreateUnitValue(50, '%')]
16118
+ transformOrigin: runtime.enableCSSParsing ? null : [PECENTAGE_50, PECENTAGE_50]
16120
16119
  }
16121
16120
  }, rest)) || this;
16122
16121
  }
@@ -16204,7 +16203,7 @@
16204
16203
  }, style) : _extends({}, style),
16205
16204
  initialParsedStyle: {
16206
16205
  anchor: [0.5, 0.5],
16207
- transformOrigin: runtime.enableCSSParsing ? null : [getOrCreateUnitValue(50, '%'), getOrCreateUnitValue(50, '%')]
16206
+ transformOrigin: runtime.enableCSSParsing ? null : [PECENTAGE_50, PECENTAGE_50]
16208
16207
  }
16209
16208
  }, rest)) || this;
16210
16209
  }
@@ -17062,7 +17061,6 @@
17062
17061
  var _proto = Text.prototype;
17063
17062
  _proto.getComputedTextLength = function getComputedTextLength() {
17064
17063
  var _this$parsedStyle$met;
17065
- this.forceUpdateGeometry();
17066
17064
  return ((_this$parsedStyle$met = this.parsedStyle.metrics) === null || _this$parsedStyle$met === void 0 ? void 0 : _this$parsedStyle$met.maxLineWidth) || 0;
17067
17065
  }
17068
17066
  // getEndPositionOfChar(charnum: number): DOMPoint {
@@ -17089,18 +17087,11 @@
17089
17087
  ;
17090
17088
  _proto.getLineBoundingRects = function getLineBoundingRects() {
17091
17089
  var _this$parsedStyle$met2;
17092
- this.forceUpdateGeometry();
17093
17090
  return ((_this$parsedStyle$met2 = this.parsedStyle.metrics) === null || _this$parsedStyle$met2 === void 0 ? void 0 : _this$parsedStyle$met2.lineMetrics) || [];
17094
17091
  };
17095
17092
  _proto.isOverflowing = function isOverflowing() {
17096
- this.forceUpdateGeometry();
17097
17093
  return !!this.parsedStyle.isOverflowing;
17098
17094
  };
17099
- _proto.forceUpdateGeometry = function forceUpdateGeometry() {
17100
- if (!this.parsedStyle.metrics) {
17101
- runtime.styleValueRegistry.updateGeometry(this);
17102
- }
17103
- };
17104
17095
  return Text;
17105
17096
  }(DisplayObject);
17106
17097
 
@@ -17464,6 +17455,10 @@
17464
17455
  // Polyline & Polygon
17465
17456
  {
17466
17457
  n: 'points',
17458
+ /**
17459
+ * support interpolation
17460
+ */
17461
+ int: true,
17467
17462
  l: true,
17468
17463
  syntax: exports.PropertySyntax.LIST_OF_POINTS,
17469
17464
  p: 50
@@ -17832,8 +17827,7 @@
17832
17827
  runtime.CSSPropertySyntaxFactory['<transform>'].postProcessor(object, _attributeNames);
17833
17828
  }
17834
17829
  if (_needUpdateGeometry) {
17835
- object.geometry.dirty = true;
17836
- runtime.sceneGraphService.dirtifyToRoot(object);
17830
+ this.updateGeometry(object);
17837
17831
  }
17838
17832
  return;
17839
17833
  }
@@ -17899,8 +17893,9 @@
17899
17893
  // }
17900
17894
  // update geometry
17901
17895
  if (needUpdateGeometry) {
17902
- object.geometry.dirty = true;
17903
- runtime.sceneGraphService.dirtifyToRoot(object);
17896
+ // object.geometry.dirty = true;
17897
+ // runtime.sceneGraphService.dirtifyToRoot(object);
17898
+ this.updateGeometry(object);
17904
17899
  }
17905
17900
  attributeNames.forEach(function (name) {
17906
17901
  if (name in object.parsedStyle) {
@@ -18075,7 +18070,8 @@
18075
18070
  * eg. r of Circle, width/height of Rect
18076
18071
  */;
18077
18072
  _proto.updateGeometry = function updateGeometry(object) {
18078
- var geometryUpdater = runtime.geometryUpdaterFactory[object.nodeName];
18073
+ var nodeName = object.nodeName;
18074
+ var geometryUpdater = runtime.geometryUpdaterFactory[nodeName];
18079
18075
  if (geometryUpdater) {
18080
18076
  var geometry = object.geometry;
18081
18077
  if (!geometry.contentBounds) {
@@ -18096,10 +18092,6 @@
18096
18092
  offsetY = _geometryUpdater$upda4 === void 0 ? 0 : _geometryUpdater$upda4,
18097
18093
  _geometryUpdater$upda5 = _geometryUpdater$upda.offsetZ,
18098
18094
  offsetZ = _geometryUpdater$upda5 === void 0 ? 0 : _geometryUpdater$upda5;
18099
- // account for negative width / height of Rect
18100
- // @see https://github.com/antvis/g/issues/957
18101
- var flipY = width < 0;
18102
- var flipX = height < 0;
18103
18095
  // init with content box
18104
18096
  var halfExtents = [Math.abs(width) / 2, Math.abs(height) / 2, depth / 2];
18105
18097
  // const halfExtents = vec3.set(
@@ -18119,7 +18111,7 @@
18119
18111
  transformOrigin = parsedStyle.transformOrigin;
18120
18112
  var anchor = parsedStyle.anchor;
18121
18113
  // <Text> use textAlign & textBaseline instead of anchor
18122
- if (object.nodeName === exports.Shape.TEXT) {
18114
+ if (nodeName === exports.Shape.TEXT) {
18123
18115
  delete parsedStyle.anchor;
18124
18116
  }
18125
18117
  var center = [(1 - (anchor && anchor[0] || 0) * 2) * width / 2 + offsetX, (1 - (anchor && anchor[1] || 0) * 2) * height / 2 + offsetY, (1 - (anchor && anchor[2] || 0) * 2) * halfExtents[2] + offsetZ];
@@ -18132,7 +18124,7 @@
18132
18124
  // update geometry's AABB
18133
18125
  geometry.contentBounds.update(center, halfExtents);
18134
18126
  // @see https://github.molgen.mpg.de/git-mirror/cairo/blob/master/src/cairo-stroke-style.c#L97..L128
18135
- var expansion = object.nodeName === exports.Shape.POLYLINE || object.nodeName === exports.Shape.POLYGON || object.nodeName === exports.Shape.PATH ? Math.SQRT2 : 0.5;
18127
+ var expansion = nodeName === exports.Shape.POLYLINE || nodeName === exports.Shape.POLYGON || nodeName === exports.Shape.PATH ? Math.SQRT2 : 0.5;
18136
18128
  // if (lineCap?.value === 'square') {
18137
18129
  // expansion = Math.SQRT1_2;
18138
18130
  // }
@@ -18202,16 +18194,21 @@
18202
18194
  }
18203
18195
  });
18204
18196
  anchor = parsedStyle.anchor;
18205
- geometry.dirty = false;
18197
+ // if (nodeName === Shape.RECT) {
18198
+ // account for negative width / height of Rect
18199
+ // @see https://github.com/antvis/g/issues/957
18200
+ var flipY = width < 0;
18201
+ var flipX = height < 0;
18202
+ // } else {
18203
+ // }
18206
18204
  // set transform origin
18207
18205
  var usedOriginXValue = (flipY ? -1 : 1) * (transformOrigin ? convertPercentUnit(transformOrigin[0], 0, object) : 0);
18208
18206
  var usedOriginYValue = (flipX ? -1 : 1) * (transformOrigin ? convertPercentUnit(transformOrigin[1], 1, object) : 0);
18209
18207
  usedOriginXValue = usedOriginXValue - (flipY ? -1 : 1) * (anchor && anchor[0] || 0) * geometry.contentBounds.halfExtents[0] * 2;
18210
18208
  usedOriginYValue = usedOriginYValue - (flipX ? -1 : 1) * (anchor && anchor[1] || 0) * geometry.contentBounds.halfExtents[1] * 2;
18211
18209
  object.setOrigin(usedOriginXValue, usedOriginYValue);
18212
- // console.log('calc geometry', object);
18213
18210
  // FIXME setOrigin may have already dirtified to root.
18214
- // runtime.sceneGraphService.dirtifyToRoot(object);
18211
+ runtime.sceneGraphService.dirtifyToRoot(object);
18215
18212
  }
18216
18213
  };
18217
18214
  _proto.isPropertyInheritable = function isPropertyInheritable(name) {
@@ -20767,10 +20764,10 @@
20767
20764
  z = 0;
20768
20765
  }
20769
20766
  if (typeof origin === 'number') {
20770
- origin = fromValues$2(origin, y, z);
20767
+ origin = [origin, y, z];
20771
20768
  }
20772
20769
  var transform = element.transformable;
20773
- if (equals$1(origin, transform.origin)) {
20770
+ if (origin[0] === transform.origin[0] && origin[1] === transform.origin[1] && origin[2] === transform.origin[2]) {
20774
20771
  return;
20775
20772
  }
20776
20773
  var originVec = transform.origin;
@@ -21046,9 +21043,6 @@
21046
21043
  render = false;
21047
21044
  }
21048
21045
  var geometry = element.geometry;
21049
- if (geometry.dirty) {
21050
- runtime.styleValueRegistry.updateGeometry(element);
21051
- }
21052
21046
  var bounds = render ? geometry.renderBounds : geometry.contentBounds || null;
21053
21047
  // return (bounds && new AABB(bounds.center, bounds.halfExtents)) || new AABB();
21054
21048
  return bounds || new AABB();
@@ -21090,7 +21084,7 @@
21090
21084
  var clipped = findClosestClipPathTarget(element);
21091
21085
  if (clipped) {
21092
21086
  // use bounds under world space
21093
- var clipPathBounds = clipped.style.clipPath.getBounds(render);
21087
+ var clipPathBounds = clipped.parsedStyle.clipPath.getBounds(render);
21094
21088
  if (!aabb) {
21095
21089
  aabb = clipPathBounds;
21096
21090
  } else if (clipPathBounds) {
@@ -21367,19 +21361,19 @@
21367
21361
  leading = _parsedStyle$leading === void 0 ? 0 : _parsedStyle$leading;
21368
21362
  var font = toFontString(parsedStyle);
21369
21363
  var fontProperties;
21370
- if (runtime.enableCSSParsing) {
21371
- fontProperties = this.measureFont(font, offscreenCanvas);
21372
- // fallback in case UA disallow canvas data extraction
21373
- // (toDataURI, getImageData functions)
21374
- if (fontProperties.fontSize === 0) {
21375
- fontProperties.fontSize = fontSize;
21376
- fontProperties.ascent = fontSize;
21377
- }
21378
- } else {
21379
- fontProperties = {
21380
- fontSize: fontSize
21381
- };
21382
- }
21364
+ // if (runtime.enableCSSParsing) {
21365
+ fontProperties = this.measureFont(font, offscreenCanvas);
21366
+ // fallback in case UA disallow canvas data extraction
21367
+ // (toDataURI, getImageData functions)
21368
+ if (fontProperties.fontSize === 0) {
21369
+ fontProperties.fontSize = fontSize;
21370
+ fontProperties.ascent = fontSize;
21371
+ }
21372
+ // } else {
21373
+ // fontProperties = {
21374
+ // fontSize,
21375
+ // };
21376
+ // }
21383
21377
  var context = this.runtime.offscreenCanvas.getOrCreateContext(offscreenCanvas);
21384
21378
  context.font = font;
21385
21379
  // no overflowing by default
@@ -21828,7 +21822,7 @@
21828
21822
  var normalizedEvents = _this.normalizeToPointerEvent(nativeEvent, canvas);
21829
21823
  for (var _iterator = _createForOfIteratorHelperLoose(normalizedEvents), _step; !(_step = _iterator()).done;) {
21830
21824
  var normalizedEvent = _step.value;
21831
- var event = _this.bootstrapEvent(_this.rootPointerEvent, normalizedEvent, canvas);
21825
+ var event = _this.bootstrapEvent(_this.rootPointerEvent, normalizedEvent, canvas, nativeEvent);
21832
21826
  _this.context.eventService.mapEvent(event);
21833
21827
  }
21834
21828
  _this.setCursor(_this.context.eventService.cursor);
@@ -21883,7 +21877,7 @@
21883
21877
  }
21884
21878
  for (var _iterator2 = _createForOfIteratorHelperLoose(events), _step2; !(_step2 = _iterator2()).done;) {
21885
21879
  var event = _step2.value;
21886
- var federatedEvent = _this2.bootstrapEvent(_this2.rootPointerEvent, event, canvas);
21880
+ var federatedEvent = _this2.bootstrapEvent(_this2.rootPointerEvent, event, canvas, nativeEvent);
21887
21881
  _this2.context.eventService.mapEvent(federatedEvent);
21888
21882
  }
21889
21883
  _this2.setCursor(_this2.context.eventService.cursor);
@@ -21902,7 +21896,7 @@
21902
21896
  var normalizedEvents = _this2.normalizeToPointerEvent(nativeEvent, canvas);
21903
21897
  for (var _iterator3 = _createForOfIteratorHelperLoose(normalizedEvents), _step3; !(_step3 = _iterator3()).done;) {
21904
21898
  var normalizedEvent = _step3.value;
21905
- var event = _this2.bootstrapEvent(_this2.rootPointerEvent, normalizedEvent, canvas);
21899
+ var event = _this2.bootstrapEvent(_this2.rootPointerEvent, normalizedEvent, canvas, nativeEvent);
21906
21900
  event.type += outside;
21907
21901
  _this2.context.eventService.mapEvent(event);
21908
21902
  }
@@ -21937,22 +21931,22 @@
21937
21931
  y: y
21938
21932
  };
21939
21933
  };
21940
- _proto.bootstrapEvent = function bootstrapEvent(event, nativeEvent, view) {
21934
+ _proto.bootstrapEvent = function bootstrapEvent(event, normalizedEvent, view, nativeEvent) {
21941
21935
  event.view = view;
21942
21936
  event.originalEvent = null;
21943
21937
  event.nativeEvent = nativeEvent;
21944
- event.pointerId = nativeEvent.pointerId;
21945
- event.width = nativeEvent.width;
21946
- event.height = nativeEvent.height;
21947
- event.isPrimary = nativeEvent.isPrimary;
21948
- event.pointerType = nativeEvent.pointerType;
21949
- event.pressure = nativeEvent.pressure;
21950
- event.tangentialPressure = nativeEvent.tangentialPressure;
21951
- event.tiltX = nativeEvent.tiltX;
21952
- event.tiltY = nativeEvent.tiltY;
21953
- event.twist = nativeEvent.twist;
21954
- this.transferMouseData(event, nativeEvent);
21955
- var _this$getViewportXY = this.getViewportXY(nativeEvent),
21938
+ event.pointerId = normalizedEvent.pointerId;
21939
+ event.width = normalizedEvent.width;
21940
+ event.height = normalizedEvent.height;
21941
+ event.isPrimary = normalizedEvent.isPrimary;
21942
+ event.pointerType = normalizedEvent.pointerType;
21943
+ event.pressure = normalizedEvent.pressure;
21944
+ event.tangentialPressure = normalizedEvent.tangentialPressure;
21945
+ event.tiltX = normalizedEvent.tiltX;
21946
+ event.tiltY = normalizedEvent.tiltY;
21947
+ event.twist = normalizedEvent.twist;
21948
+ this.transferMouseData(event, normalizedEvent);
21949
+ var _this$getViewportXY = this.getViewportXY(normalizedEvent),
21956
21950
  x = _this$getViewportXY.x,
21957
21951
  y = _this$getViewportXY.y;
21958
21952
  event.viewport.x = x;