xtk / X

The X Toolkit
http://www.goXTK.com
Other
795 stars 266 forks source link

X orientation renderer2D mixing up dimesions #174

Open nrhorner opened 9 years ago

nrhorner commented 9 years ago

Hi,

I noticed that the sagittal (x) slice was not resizing properly and found that the _sliceWidth and _sliceHeight variables are getting switched somehow.

I have made a quick bodge to fix this issue for myself.

X.renderer2D.prototype.autoScale_ = function() {

  // let's auto scale for best fit
   if (this._orientationIndex == 0) {
      //nrhorner: Switch the dimesions of the sagittal slice
      var h = this._sliceHeight;
      var w = this._sliceWidth;
      this._sliceWidth = h;
      this._sliceHeight = w;
  }
  var _wScale = this._width / (this._sliceWidth * this._sliceWidthSpacing);
  var _hScale = this._height / (this._sliceHeight * this._sliceHeightSpacing);

  var _autoScale = Math.min(_wScale, _hScale);

  // propagate scale (zoom) to the camera
  var _view = this._camera._view;
  _view[14] = _autoScale;

};