Skip to content

Commit

Permalink
Apply offset to draw layers
Browse files Browse the repository at this point in the history
  • Loading branch information
ivmartel committed Aug 14, 2023
1 parent d26fbe2 commit a1fd844
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/gui/layerGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -801,14 +801,15 @@ export class LayerGroup {
// origin of the first view layer
let baseViewLayerOrigin0;
let baseViewLayerOrigin;
let scrollOffset;
let planeOffset;
// update position for all layers except the source one
for (let i = 0; i < this.#layers.length; ++i) {
if (typeof this.#layers[i] === 'undefined') {
continue;
}

// update base offset (does not trigger redraw)
// TODO check draw layers update
let hasSetOffset = false;
if (this.#layers[i] instanceof ViewLayer) {
const vc = this.#layers[i].getViewController();
Expand All @@ -824,20 +825,22 @@ export class LayerGroup {
if (vc.canSetPosition(position) &&
typeof origin !== 'undefined') {
// TODO: compensate for possible different orientation between views

const scrollDiff = baseViewLayerOrigin0.minus(origin0);
const scrollOffset = new Vector3D(
scrollOffset = new Vector3D(
scrollDiff.getX(), scrollDiff.getY(), scrollDiff.getZ());

const planeDiff = baseViewLayerOrigin.minus(origin);
const planeOffset = new Vector3D(
planeOffset = new Vector3D(
planeDiff.getX(), planeDiff.getY(), planeDiff.getZ());

hasSetOffset =
this.#layers[i].setBaseOffset(scrollOffset, planeOffset);
}
}
}
// also set for draw layers
// (should be next after a view layer)
if (typeof scrollOffset !== 'undefined' &&
typeof planeOffset !== 'undefined') {
hasSetOffset =
this.#layers[i].setBaseOffset(scrollOffset, planeOffset);
}

// update position (triggers redraw)
let hasSetPos = false;
Expand Down

0 comments on commit a1fd844

Please sign in to comment.