Skip to content

Commit

Permalink
Appropriate displacement scaling
Browse files Browse the repository at this point in the history
  • Loading branch information
joakimlindblad authored and Joakim Lindblad committed Dec 24, 2023
1 parent 2f81e32 commit 475b289
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions public/js/tmapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,19 +170,21 @@ const tmapp = (function() {
const position = _viewer.viewport.getCenter();
_currState.x = position.x;
_currState.y = position.y;

//update additional viewers
const plus = (a,b) => ({x:a.x+b.x, y:a.y+b.y});
const minus = (a,b) => ({x:a.x-b.x, y:a.y-b.y});
const scale = (a,b) => ({x:a.x*b, y:a.y*b});
_viewers.forEach(v => {
if (v===_viewer) {
return;
}
const scaledPosition=scale(position,1/v.transform.scale);
if (v.freeze) {
v.transform.position=minus(v.viewport.getCenter(),position);
v.transform.position=minus(v.viewport.getCenter(),scaledPosition);
console.log('Position: ',v.transform.position);
}
v.viewport.panTo(plus(position,v.transform.position)); //NOP if frozen
v.viewport.panTo(plus(scaledPosition,v.transform.position)); //NOP if frozen
});

_updateCollabPosition();
Expand Down

0 comments on commit 475b289

Please sign in to comment.