@visactor/vrender 0.11.2-alpha.1 → 0.12.1

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.
Files changed (92) hide show
  1. package/cjs/animate/custom-animate.d.ts +3 -3
  2. package/cjs/animate/custom-animate.js +1 -1
  3. package/cjs/animate/custom-animate.js.map +1 -1
  4. package/cjs/animate/easing.d.ts +6 -0
  5. package/cjs/animate/easing.js +18 -0
  6. package/cjs/animate/easing.js.map +1 -1
  7. package/cjs/canvas/contributions/browser/context.d.ts +4 -2
  8. package/cjs/canvas/contributions/browser/context.js +3 -2
  9. package/cjs/canvas/contributions/browser/context.js.map +1 -1
  10. package/cjs/canvas/contributions/lynx/context.d.ts +2 -1
  11. package/cjs/canvas/contributions/lynx/context.js +8 -0
  12. package/cjs/canvas/contributions/lynx/context.js.map +1 -1
  13. package/cjs/common/text.js +2 -1
  14. package/cjs/common/text.js.map +1 -1
  15. package/cjs/core/stage.d.ts +23 -1
  16. package/cjs/core/stage.js +14 -9
  17. package/cjs/core/stage.js.map +1 -1
  18. package/cjs/graphic/config.js +2 -1
  19. package/cjs/graphic/config.js.map +1 -1
  20. package/cjs/graphic/graphic-service/graphic-service.js +6 -1
  21. package/cjs/graphic/graphic-service/graphic-service.js.map +1 -1
  22. package/cjs/graphic/richtext/wrapper.d.ts +2 -2
  23. package/cjs/graphic/richtext/wrapper.js +2 -2
  24. package/cjs/graphic/richtext/wrapper.js.map +1 -1
  25. package/cjs/index.d.ts +1 -1
  26. package/cjs/index.js +18 -18
  27. package/cjs/index.js.map +1 -1
  28. package/cjs/interface/animate.d.ts +1 -1
  29. package/cjs/interface/animate.js.map +1 -1
  30. package/cjs/interface/context.d.ts +1 -0
  31. package/cjs/interface/context.js.map +1 -1
  32. package/cjs/interface/graphic/text.d.ts +1 -0
  33. package/cjs/interface/graphic/text.js.map +1 -1
  34. package/cjs/interface/render.d.ts +1 -1
  35. package/cjs/interface/render.js.map +1 -1
  36. package/cjs/interface/stage.d.ts +9 -2
  37. package/cjs/interface/stage.js.map +1 -1
  38. package/cjs/plugins/builtin-plugin/3dview-transform-plugin.js +4 -2
  39. package/cjs/plugins/builtin-plugin/3dview-transform-plugin.js.map +1 -1
  40. package/cjs/render/contributions/render/draw-contribution.d.ts +1 -1
  41. package/cjs/render/contributions/render/draw-contribution.js +4 -2
  42. package/cjs/render/contributions/render/draw-contribution.js.map +1 -1
  43. package/cjs/render/contributions/render/draw-interceptor.js +1 -1
  44. package/cjs/render/contributions/render/draw-interceptor.js.map +1 -1
  45. package/dist/index.js +100 -27
  46. package/dist/index.min.js +1 -1
  47. package/es/animate/custom-animate.d.ts +3 -3
  48. package/es/animate/custom-animate.js +1 -1
  49. package/es/animate/custom-animate.js.map +1 -1
  50. package/es/animate/easing.d.ts +6 -0
  51. package/es/animate/easing.js +18 -0
  52. package/es/animate/easing.js.map +1 -1
  53. package/es/canvas/contributions/browser/context.d.ts +4 -2
  54. package/es/canvas/contributions/browser/context.js +3 -1
  55. package/es/canvas/contributions/browser/context.js.map +1 -1
  56. package/es/canvas/contributions/lynx/context.d.ts +2 -1
  57. package/es/canvas/contributions/lynx/context.js +8 -0
  58. package/es/canvas/contributions/lynx/context.js.map +1 -1
  59. package/es/common/text.js +2 -1
  60. package/es/common/text.js.map +1 -1
  61. package/es/core/stage.d.ts +23 -1
  62. package/es/core/stage.js +14 -9
  63. package/es/core/stage.js.map +1 -1
  64. package/es/graphic/config.js +2 -1
  65. package/es/graphic/config.js.map +1 -1
  66. package/es/graphic/graphic-service/graphic-service.js +6 -1
  67. package/es/graphic/graphic-service/graphic-service.js.map +1 -1
  68. package/es/graphic/richtext/wrapper.d.ts +2 -2
  69. package/es/graphic/richtext/wrapper.js +2 -2
  70. package/es/graphic/richtext/wrapper.js.map +1 -1
  71. package/es/index.d.ts +1 -1
  72. package/es/index.js +1 -1
  73. package/es/index.js.map +1 -1
  74. package/es/interface/animate.d.ts +1 -1
  75. package/es/interface/animate.js.map +1 -1
  76. package/es/interface/context.d.ts +1 -0
  77. package/es/interface/context.js.map +1 -1
  78. package/es/interface/graphic/text.d.ts +1 -0
  79. package/es/interface/graphic/text.js.map +1 -1
  80. package/es/interface/render.d.ts +1 -1
  81. package/es/interface/render.js.map +1 -1
  82. package/es/interface/stage.d.ts +9 -2
  83. package/es/interface/stage.js.map +1 -1
  84. package/es/plugins/builtin-plugin/3dview-transform-plugin.js +4 -2
  85. package/es/plugins/builtin-plugin/3dview-transform-plugin.js.map +1 -1
  86. package/es/render/contributions/render/draw-contribution.d.ts +1 -1
  87. package/es/render/contributions/render/draw-contribution.js +4 -2
  88. package/es/render/contributions/render/draw-contribution.js.map +1 -1
  89. package/es/render/contributions/render/draw-interceptor.js +1 -1
  90. package/es/render/contributions/render/draw-interceptor.js.map +1 -1
  91. package/es/tsconfig.tsbuildinfo +1 -1
  92. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -4206,6 +4206,10 @@
4206
4206
  function __metadata(metadataKey, metadataValue) {
4207
4207
  if ((typeof Reflect === "undefined" ? "undefined" : _typeof(Reflect)) === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
4208
4208
  }
4209
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
4210
+ var e = new Error(message);
4211
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
4212
+ };
4209
4213
 
4210
4214
  const ContributionProvider = Symbol('ContributionProvider');
4211
4215
  class ContributionProviderCache {
@@ -7548,7 +7552,8 @@
7548
7552
  fontStyle: '',
7549
7553
  lineHeight: undefined,
7550
7554
  underline: 0,
7551
- lineThrough: 0
7555
+ lineThrough: 0,
7556
+ scaleIn3d: false
7552
7557
  };
7553
7558
  const DefaultStyle = {
7554
7559
  opacity: 1,
@@ -11485,6 +11490,24 @@
11485
11490
  static backIn = Easing.getBackIn(1.7);
11486
11491
  static backOut = Easing.getBackOut(1.7);
11487
11492
  static backInOut = Easing.getBackInOut(1.7);
11493
+ static sineIn(t) {
11494
+ return 1 - Math.cos((t * Math.PI) / 2);
11495
+ }
11496
+ static sineOut(t) {
11497
+ return Math.sin((t * Math.PI) / 2);
11498
+ }
11499
+ static sineInOut(t) {
11500
+ return -(Math.cos(Math.PI * t) - 1) / 2;
11501
+ }
11502
+ static expoIn(t) {
11503
+ return t === 0 ? 0 : Math.pow(2, 10 * t - 10);
11504
+ }
11505
+ static expoOut(t) {
11506
+ return t === 1 ? 1 : 1 - Math.pow(2, -10 * t);
11507
+ }
11508
+ static expoInOut(t) {
11509
+ return t === 0 ? 0 : t === 1 ? 1 : t < 0.5 ? Math.pow(2, 20 * t - 10) / 2 : (2 - Math.pow(2, -20 * t + 10)) / 2;
11510
+ }
11488
11511
  static circIn(t) {
11489
11512
  return -(Math.sqrt(1 - t * t) - 1);
11490
11513
  }
@@ -12584,6 +12607,12 @@
12584
12607
  return;
12585
12608
  }
12586
12609
  onUpdate(end, ratio, out) {
12610
+ if (!this.toFill) {
12611
+ return;
12612
+ }
12613
+ if (!this.toStroke) {
12614
+ return;
12615
+ }
12587
12616
  switch (this.direction) {
12588
12617
  case Direction.RIGHT_TO_LEFT:
12589
12618
  this.rightToLeft(end, ratio, out);
@@ -17355,7 +17384,9 @@
17355
17384
  }
17356
17385
 
17357
17386
  function getContextFont(text, defaultAttr = {}, fontSizeScale) {
17358
- fontSizeScale = 1;
17387
+ if (!fontSizeScale) {
17388
+ fontSizeScale = 1;
17389
+ }
17359
17390
  const { fontStyle = defaultAttr.fontStyle, fontVariant = defaultAttr.fontVariant, fontWeight = defaultAttr.fontWeight, fontSize = defaultAttr.fontSize, fontFamily = defaultAttr.fontFamily } = text;
17360
17391
  return ('' +
17361
17392
  (fontStyle ? fontStyle + ' ' : '') +
@@ -19905,6 +19936,10 @@
19905
19936
  if (this.lineWidth + paragraph[this.directionKey.width] <= this[this.directionKey.width]) {
19906
19937
  this.store(paragraph);
19907
19938
  }
19939
+ else if (this.lineBuffer.length === 0) {
19940
+ this.store(paragraph);
19941
+ this.send();
19942
+ }
19908
19943
  else {
19909
19944
  this.send();
19910
19945
  this.deal(paragraph);
@@ -21804,7 +21839,13 @@
21804
21839
  return aabbBounds;
21805
21840
  }
21806
21841
  updateArcAABBBoundsAccurate(attribute, arcTheme, aabbBounds, graphic) {
21807
- const { outerRadius = arcTheme.outerRadius, innerRadius = arcTheme.innerRadius, endAngle = arcTheme.endAngle, startAngle = arcTheme.startAngle } = attribute;
21842
+ const { outerRadius = arcTheme.outerRadius, innerRadius = arcTheme.innerRadius } = attribute;
21843
+ let { endAngle = arcTheme.endAngle, startAngle = arcTheme.startAngle } = attribute;
21844
+ if (startAngle > endAngle) {
21845
+ const temp = startAngle;
21846
+ startAngle = endAngle;
21847
+ endAngle = temp;
21848
+ }
21808
21849
  if (outerRadius <= epsilon) {
21809
21850
  aabbBounds.set(0, 0, 0, 0);
21810
21851
  }
@@ -26358,11 +26399,12 @@
26358
26399
  if (!defaultParams) {
26359
26400
  defaultParams = this.textAttributes;
26360
26401
  }
26402
+ const { scaleIn3d = defaultParams.scaleIn3d } = params;
26361
26403
  if (params.font) {
26362
26404
  _context.font = params.font;
26363
26405
  }
26364
26406
  else {
26365
- _context.font = getContextFont(params, defaultParams, this.camera && this.camera.getProjectionScale(z));
26407
+ _context.font = getContextFont(params, defaultParams, scaleIn3d && this.camera && this.camera.getProjectionScale(z));
26366
26408
  }
26367
26409
  const { fontFamily = defaultParams.fontFamily, fontSize = defaultParams.fontSize } = params;
26368
26410
  this.fontFamily = fontFamily;
@@ -28879,6 +28921,17 @@
28879
28921
  this.nativeContext.globalAlpha = ga;
28880
28922
  this._globalAlpha = ga;
28881
28923
  }
28924
+ setLineDash(segments) {
28925
+ const a = arguments;
28926
+ const _context = this.nativeContext;
28927
+ if (!!this.nativeContext.setLineDash) {
28928
+ const lineDash = a[0];
28929
+ if (lineDash[0] === 0 && lineDash[1] === 0) {
28930
+ return;
28931
+ }
28932
+ _context.setLineDash(lineDash);
28933
+ }
28934
+ }
28882
28935
  draw() {
28883
28936
  const _context = this.nativeContext;
28884
28937
  this.drawPromise = new Promise(resolve => {
@@ -29810,7 +29863,7 @@
29810
29863
  zChildren.forEach(i => {
29811
29864
  graphic.add(i.g);
29812
29865
  });
29813
- drawContribution.renderGroup(graphic, drawContext);
29866
+ drawContribution.renderGroup(graphic, drawContext, true);
29814
29867
  graphic.removeAllChild();
29815
29868
  children.forEach(g => {
29816
29869
  g._next = null;
@@ -29939,7 +29992,7 @@
29939
29992
  }
29940
29993
  return null;
29941
29994
  }
29942
- renderGroup(group, drawContext) {
29995
+ renderGroup(group, drawContext, skipSort) {
29943
29996
  if (drawContext.break || group.attribute.visibleAll === false) {
29944
29997
  return;
29945
29998
  }
@@ -29956,17 +30009,29 @@
29956
30009
  this.dirtyBounds.copy(this.backupDirtyBounds).transformWithMatrix(m);
29957
30010
  this.renderItem(group, drawContext, {
29958
30011
  drawingCb: () => {
29959
- foreach(group, DefaultAttribute.zIndex, (item) => {
29960
- if (drawContext.break) {
29961
- return;
29962
- }
29963
- if (item.isContainer) {
29964
- this.renderGroup(item, drawContext);
29965
- }
29966
- else {
29967
- this.renderItem(item, drawContext);
29968
- }
29969
- }, false, !!drawContext.context?.camera);
30012
+ skipSort
30013
+ ? group.forEachChildren((item) => {
30014
+ if (drawContext.break) {
30015
+ return;
30016
+ }
30017
+ if (item.isContainer) {
30018
+ this.renderGroup(item, drawContext);
30019
+ }
30020
+ else {
30021
+ this.renderItem(item, drawContext);
30022
+ }
30023
+ })
30024
+ : foreach(group, DefaultAttribute.zIndex, (item) => {
30025
+ if (drawContext.break) {
30026
+ return;
30027
+ }
30028
+ if (item.isContainer) {
30029
+ this.renderGroup(item, drawContext);
30030
+ }
30031
+ else {
30032
+ this.renderItem(item, drawContext);
30033
+ }
30034
+ }, false, !!drawContext.context?.camera);
29970
30035
  }
29971
30036
  });
29972
30037
  this.dirtyBounds.copy(tempBounds);
@@ -32913,8 +32978,8 @@
32913
32978
  this.pageY = e.page.y;
32914
32979
  const angle1 = deltaX / 100;
32915
32980
  const angle2 = deltaY / 100;
32916
- this.option3d.alpha += angle1;
32917
- this.option3d.beta += angle2;
32981
+ this.option3d.alpha = (this.option3d.alpha ?? 0) + angle1;
32982
+ this.option3d.beta = (this.option3d.beta ?? 0) + angle2;
32918
32983
  stage.set3dOptions(this.option3d);
32919
32984
  stage.renderNextFrame();
32920
32985
  }
@@ -33278,9 +33343,9 @@
33278
33343
  this._afterRender = params.afterRender;
33279
33344
  this.ticker = params.ticker || defaultTicker;
33280
33345
  }
33281
- set3dOptions(options) {
33282
- const { center = { x: this.width / 2, y: this.height / 2 }, light = {}, alpha = 0, beta = 0, camera, fieldRatio = 1, fieldDepth } = options;
33283
- this.option3d = {
33346
+ get3dOptions(options) {
33347
+ const { center = { x: this.width / 2, y: this.height / 2, z: 0, dx: 0, dy: 0, dz: 0 }, light = {}, alpha = 0, beta = 0, camera, fieldRatio = 1, fieldDepth } = options;
33348
+ return {
33284
33349
  ...options,
33285
33350
  center,
33286
33351
  light,
@@ -33290,15 +33355,23 @@
33290
33355
  fieldRatio,
33291
33356
  fieldDepth
33292
33357
  };
33358
+ }
33359
+ set3dOptions(options) {
33360
+ this.option3d = options;
33361
+ const options3d = this.get3dOptions(options);
33362
+ const { light, center, camera, alpha, beta, fieldRatio, fieldDepth } = options3d;
33293
33363
  const { dir = [1, 1, -1], color = 'white', ambient } = light;
33294
- const centerVec3 = [center.x, center.y, 0];
33364
+ const centerX = (center.x ?? this.width / 2) + (center.dx ?? 0);
33365
+ const centerY = (center.y ?? this.height / 2) + (center.dy ?? 0);
33366
+ const centerZ = (center.z ?? 0) + (center.dz ?? 0);
33367
+ const centerVec3 = [centerX, centerY, centerZ];
33295
33368
  const z = 1;
33296
33369
  let cameraX = 0;
33297
33370
  let cameraY = 0;
33298
33371
  let cameraZ = 0;
33299
33372
  if (!camera) {
33300
- cameraX = Math.sin(alpha) + center.x;
33301
- cameraY = Math.sin(beta) + center.y;
33373
+ cameraX = Math.sin(alpha) + centerX;
33374
+ cameraY = Math.sin(beta) + centerY;
33302
33375
  cameraZ = Math.cos(alpha) * Math.cos(beta) * z;
33303
33376
  }
33304
33377
  this.light = new DirectionalLight(dir, color, ambient);
@@ -33512,7 +33585,7 @@
33512
33585
  if (!this._subView) {
33513
33586
  this.viewBox.setValue(this.viewBox.x1, this.viewBox.y1, this.viewBox.x1 + w, this.viewBox.y1 + h);
33514
33587
  }
33515
- this.camera && (this.camera.params = { ...this.camera.params, right: this.width, bottom: this.height });
33588
+ this.camera && this.option3d && this.set3dOptions(this.option3d);
33516
33589
  rerender && this.render();
33517
33590
  }
33518
33591
  resizeView(w, h, rerender = true) {
@@ -33670,7 +33743,7 @@
33670
33743
  'rect'
33671
33744
  ];
33672
33745
 
33673
- const version = "0.11.2-alpha.1";
33746
+ const version = "0.12.1";
33674
33747
 
33675
33748
  exports.ACustomAnimate = ACustomAnimate;
33676
33749
  exports.ARC3D_NUMBER_TYPE = ARC3D_NUMBER_TYPE;