Skip to content

Commit

Permalink
fix(volume loading): set the global coordinate space resolution to th…
Browse files Browse the repository at this point in the history
…e image layer resolution when loading layers (previously hardcoded)
  • Loading branch information
chrisj committed May 6, 2024
1 parent 8f78880 commit bad4456
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,28 @@ export const useLayersStore = defineStore("layers", () => {
if (!viewer) return;
viewer.layerSpecification.restoreState(layers);
viewer.navigationState.reset();
viewer.coordinateSpace.restoreState({
x: [4e-9, "m"],
y: [4e-9, "m"],
z: [40e-9, "m"],
});
return true;
const imageLayer = viewer.layerManager.managedLayers.filter(
(x) => x.name === "img"
)[0];
if (imageLayer) {
const stopListening = imageLayer.readyStateChanged.add(() => {
if (imageLayer.isReady() && imageLayer.layer) {
const { dataSources } = imageLayer.layer;
stopListening();
if (dataSources.length) {
const { loadState } = dataSources[0];
if (loadState && !loadState.error) {
const { scales } = loadState.transform.outputSpace.value;
viewer!.coordinateSpace.restoreState({
x: [scales[0], "m"],
y: [scales[1], "m"],
z: [scales[2], "m"],
});
}
}
}
});
}
}

return { initializeWithViewer, activeLayers, selectLayers };
Expand Down

0 comments on commit bad4456

Please sign in to comment.