@kitware/vtk.js 30.2.0 → 30.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -45,6 +45,22 @@ function applyTextStyle(ctx, style) {
45
45
  ctx.fillStyle = style.fontColor;
46
46
  ctx.font = `${style.fontStyle} ${style.fontSize}px ${style.fontFamily}`;
47
47
  }
48
+ function defaultGenerateTicks(publicApi, model) {
49
+ return dataBounds => {
50
+ const ticks = [];
51
+ const tickStrings = [];
52
+ for (let i = 0; i < 3; i++) {
53
+ const scale = d3.scaleLinear().domain([dataBounds[i * 2], dataBounds[i * 2 + 1]]);
54
+ ticks[i] = scale.ticks(5);
55
+ const format = scale.tickFormat(5);
56
+ tickStrings[i] = ticks[i].map(format);
57
+ }
58
+ return {
59
+ ticks,
60
+ tickStrings
61
+ };
62
+ };
63
+ }
48
64
 
49
65
  // many properties of this actor depend on the API specific view The main
50
66
  // dependency being the resolution as that drives what font sizes to use.
@@ -534,25 +550,18 @@ function vtkCubeAxesActor(publicAPI, model) {
534
550
  }
535
551
 
536
552
  // compute tick marks for axes
537
- const ticks = [];
538
- const tickStrings = [];
539
- for (let i = 0; i < 3; i++) {
540
- const scale = d3.scaleLinear().domain([model.dataBounds[i * 2], model.dataBounds[i * 2 + 1]]);
541
- ticks[i] = scale.ticks(5);
542
- const format = scale.tickFormat(5);
543
- tickStrings[i] = ticks[i].map(format);
544
- }
553
+ const t = model.generateTicks(model.dataBounds);
545
554
 
546
555
  // update gridlines / edge lines
547
- publicAPI.updatePolyData(facesToDraw, edgesToDraw, ticks);
556
+ publicAPI.updatePolyData(facesToDraw, edgesToDraw, t.ticks);
548
557
 
549
558
  // compute label world coords and text
550
- publicAPI.updateTextData(facesToDraw, edgesToDraw, ticks, tickStrings);
559
+ publicAPI.updateTextData(facesToDraw, edgesToDraw, t.ticks, t.tickStrings);
551
560
 
552
561
  // rebuild the texture only when force or changed bounds, face
553
562
  // visibility changes do to change the atlas
554
563
  if (boundsChanged || model.forceUpdate) {
555
- publicAPI.updateTextureAtlas(tickStrings);
564
+ publicAPI.updateTextureAtlas(t.tickStrings);
556
565
  }
557
566
  }
558
567
  model.forceUpdate = false;
@@ -675,7 +684,7 @@ function vtkCubeAxesActor(publicAPI, model) {
675
684
  // Object factory
676
685
  // ----------------------------------------------------------------------------
677
686
 
678
- function defaultValues(initialValues) {
687
+ function defaultValues(publicAPI, model, initialValues) {
679
688
  return {
680
689
  boundsScaleFactor: 1.3,
681
690
  camera: null,
@@ -684,20 +693,23 @@ function defaultValues(initialValues) {
684
693
  gridLines: true,
685
694
  axisLabels: null,
686
695
  axisTitlePixelOffset: 35.0,
696
+ tickLabelPixelOffset: 12.0,
697
+ generateTicks: defaultGenerateTicks(),
698
+ ...initialValues,
687
699
  axisTextStyle: {
688
700
  fontColor: 'white',
689
701
  fontStyle: 'normal',
690
702
  fontSize: 18,
691
- fontFamily: 'serif'
703
+ fontFamily: 'serif',
704
+ ...initialValues?.axisTextStyle
692
705
  },
693
- tickLabelPixelOffset: 12.0,
694
706
  tickTextStyle: {
695
707
  fontColor: 'white',
696
708
  fontStyle: 'normal',
697
709
  fontSize: 14,
698
- fontFamily: 'serif'
699
- },
700
- ...initialValues
710
+ fontFamily: 'serif',
711
+ ...initialValues?.tickTextStyle
712
+ }
701
713
  };
702
714
  }
703
715
 
@@ -705,10 +717,8 @@ function defaultValues(initialValues) {
705
717
 
706
718
  function extend(publicAPI, model) {
707
719
  let initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
708
- Object.assign(model, defaultValues(initialValues));
709
-
710
720
  // Inheritance
711
- vtkActor.extend(publicAPI, model, initialValues);
721
+ vtkActor.extend(publicAPI, model, defaultValues(publicAPI, model, initialValues));
712
722
 
713
723
  // internal variables
714
724
  model.lastFacesToDraw = [false, false, false, false, false, false];
@@ -733,7 +743,7 @@ function extend(publicAPI, model) {
733
743
  model.gridActor.setProperty(publicAPI.getProperty());
734
744
  model.gridActor.setParentProp(publicAPI);
735
745
  model.textPolyData = vtkPolyData.newInstance();
736
- macro.setGet(publicAPI, model, ['axisTitlePixelOffset', 'boundsScaleFactor', 'faceVisibilityAngle', 'gridLines', 'tickLabelPixelOffset']);
746
+ macro.setGet(publicAPI, model, ['axisTitlePixelOffset', 'boundsScaleFactor', 'faceVisibilityAngle', 'gridLines', 'tickLabelPixelOffset', 'generateTicks']);
737
747
  macro.setGetArray(publicAPI, model, ['dataBounds'], 6);
738
748
  macro.setGetArray(publicAPI, model, ['axisLabels'], 3);
739
749
  macro.get(publicAPI, model, ['axisTextStyle', 'tickTextStyle', 'camera', 'tmTexture', 'textValues', 'textPolyData', 'tickCounts', 'gridActor']);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitware/vtk.js",
3
- "version": "30.2.0",
3
+ "version": "30.3.0",
4
4
  "description": "Visualization Toolkit for the Web",
5
5
  "keywords": [
6
6
  "3d",