@expofp/renderer 1.4.0 → 1.4.2

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 (2) hide show
  1. package/dist/index.js +10 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -5061,7 +5061,15 @@ class ControlsSystem {
5061
5061
  const { maxZoom, paddingPercent } = opts;
5062
5062
  const dpr = this.renderer.context.getPixelRatio();
5063
5063
  const visibleRect = this.renderer.visibleRect;
5064
- const sourceRect = new Rect(this.viewportSystem.svgToWorld(rect.min), this.viewportSystem.svgToWorld(rect.max));
5064
+ const bearingAngle = -this.controller.azimuthAngle;
5065
+ const worldRect = new Rect(this.viewportSystem.svgToWorld(rect.min), this.viewportSystem.svgToWorld(rect.max));
5066
+ const worldPolygon = Polygon.fromRect(worldRect).rotate(bearingAngle, worldRect.center);
5067
+ const xValues = worldPolygon.vertices.map((p) => p.x);
5068
+ const yValues = worldPolygon.vertices.map((p) => p.y);
5069
+ const sourceRect = new Rect(
5070
+ [Math.min(...xValues), Math.min(...yValues)],
5071
+ [Math.max(...xValues), Math.max(...yValues)]
5072
+ );
5065
5073
  const targetRect = visibleRect ? new Rect(visibleRect.min.clone().multiplyScalar(dpr), visibleRect.max.clone().multiplyScalar(dpr)) : new Rect([0, 0], this.renderer.size);
5066
5074
  if (paddingPercent) targetRect.addPadding(targetRect.size.x * paddingPercent, targetRect.size.y * paddingPercent);
5067
5075
  const zoomByWidth = targetRect.size.x / sourceRect.size.x;
@@ -5070,7 +5078,7 @@ class ControlsSystem {
5070
5078
  const zoom = maxZoom ? Math.min(minZoom, maxZoom) : minZoom;
5071
5079
  const translate = sourceRect.center;
5072
5080
  if (visibleRect) {
5073
- const offset = new Vector2(...this.renderer.size).multiplyScalar(0.5).sub(targetRect.center).multiplyScalar(1 / zoom);
5081
+ const offset = new Vector2(...this.renderer.size).multiplyScalar(0.5).sub(targetRect.center).multiplyScalar(1 / zoom).rotateAround({ x: 0, y: 0 }, bearingAngle);
5074
5082
  translate.add(offset);
5075
5083
  }
5076
5084
  const enableTransition = !immediate;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expofp/renderer",
3
- "version": "1.4.0",
3
+ "version": "1.4.2",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"