@kitware/vtk.js 30.2.0 → 30.3.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.
@@ -45,6 +45,20 @@ 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(dataBounds) {
49
+ const ticks = [];
50
+ const tickStrings = [];
51
+ for (let i = 0; i < 3; i++) {
52
+ const scale = d3.scaleLinear().domain([dataBounds[i * 2], dataBounds[i * 2 + 1]]);
53
+ ticks[i] = scale.ticks(5);
54
+ const format = scale.tickFormat(5);
55
+ tickStrings[i] = ticks[i].map(format);
56
+ }
57
+ return {
58
+ ticks,
59
+ tickStrings
60
+ };
61
+ }
48
62
 
49
63
  // many properties of this actor depend on the API specific view The main
50
64
  // dependency being the resolution as that drives what font sizes to use.
@@ -534,25 +548,18 @@ function vtkCubeAxesActor(publicAPI, model) {
534
548
  }
535
549
 
536
550
  // 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
- }
551
+ const t = model.generateTicks(model.dataBounds);
545
552
 
546
553
  // update gridlines / edge lines
547
- publicAPI.updatePolyData(facesToDraw, edgesToDraw, ticks);
554
+ publicAPI.updatePolyData(facesToDraw, edgesToDraw, t.ticks);
548
555
 
549
556
  // compute label world coords and text
550
- publicAPI.updateTextData(facesToDraw, edgesToDraw, ticks, tickStrings);
557
+ publicAPI.updateTextData(facesToDraw, edgesToDraw, t.ticks, t.tickStrings);
551
558
 
552
559
  // rebuild the texture only when force or changed bounds, face
553
560
  // visibility changes do to change the atlas
554
561
  if (boundsChanged || model.forceUpdate) {
555
- publicAPI.updateTextureAtlas(tickStrings);
562
+ publicAPI.updateTextureAtlas(t.tickStrings);
556
563
  }
557
564
  }
558
565
  model.forceUpdate = false;
@@ -675,7 +682,7 @@ function vtkCubeAxesActor(publicAPI, model) {
675
682
  // Object factory
676
683
  // ----------------------------------------------------------------------------
677
684
 
678
- function defaultValues(initialValues) {
685
+ function defaultValues(publicAPI, model, initialValues) {
679
686
  return {
680
687
  boundsScaleFactor: 1.3,
681
688
  camera: null,
@@ -684,20 +691,23 @@ function defaultValues(initialValues) {
684
691
  gridLines: true,
685
692
  axisLabels: null,
686
693
  axisTitlePixelOffset: 35.0,
694
+ tickLabelPixelOffset: 12.0,
695
+ generateTicks: defaultGenerateTicks,
696
+ ...initialValues,
687
697
  axisTextStyle: {
688
698
  fontColor: 'white',
689
699
  fontStyle: 'normal',
690
700
  fontSize: 18,
691
- fontFamily: 'serif'
701
+ fontFamily: 'serif',
702
+ ...initialValues?.axisTextStyle
692
703
  },
693
- tickLabelPixelOffset: 12.0,
694
704
  tickTextStyle: {
695
705
  fontColor: 'white',
696
706
  fontStyle: 'normal',
697
707
  fontSize: 14,
698
- fontFamily: 'serif'
699
- },
700
- ...initialValues
708
+ fontFamily: 'serif',
709
+ ...initialValues?.tickTextStyle
710
+ }
701
711
  };
702
712
  }
703
713
 
@@ -705,10 +715,8 @@ function defaultValues(initialValues) {
705
715
 
706
716
  function extend(publicAPI, model) {
707
717
  let initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
708
- Object.assign(model, defaultValues(initialValues));
709
-
710
718
  // Inheritance
711
- vtkActor.extend(publicAPI, model, initialValues);
719
+ vtkActor.extend(publicAPI, model, defaultValues(publicAPI, model, initialValues));
712
720
 
713
721
  // internal variables
714
722
  model.lastFacesToDraw = [false, false, false, false, false, false];
@@ -721,7 +729,9 @@ function extend(publicAPI, model) {
721
729
  model._tmAtlas = new Map();
722
730
 
723
731
  // for texture atlas
724
- model.tmTexture = vtkTexture.newInstance();
732
+ model.tmTexture = vtkTexture.newInstance({
733
+ resizable: true
734
+ });
725
735
  model.tmTexture.setInterpolate(false);
726
736
  publicAPI.getProperty().setDiffuse(0.0);
727
737
  publicAPI.getProperty().setAmbient(1.0);
@@ -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']);
@@ -751,7 +761,8 @@ const newInstance = macro.newInstance(extend, 'vtkCubeAxesActor');
751
761
  var vtkCubeAxesActor$1 = {
752
762
  newInstance,
753
763
  extend,
754
- newCubeAxesActorHelper
764
+ newCubeAxesActorHelper,
765
+ defaultGenerateTicks
755
766
  };
756
767
 
757
768
  export { vtkCubeAxesActor$1 as default, extend, newInstance };
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.1",
4
4
  "description": "Visualization Toolkit for the Web",
5
5
  "keywords": [
6
6
  "3d",