-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #113 from PaulHax/camera-2d
View 2D: Reset camera with viewport aspect ratio
- Loading branch information
Showing
37 changed files
with
773 additions
and
582 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
'@itk-viewer/remote-viewport': patch | ||
'@itk-viewer/blosc-zarr': patch | ||
'@itk-viewer/arcball': patch | ||
'@itk-viewer/element': patch | ||
'@itk-viewer/viewer': patch | ||
'@itk-viewer/utils': patch | ||
'@itk-viewer/vtkjs': patch | ||
'@itk-viewer/io': patch | ||
--- | ||
|
||
Add orthographic camera and zooming to 2D view. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ micromamba/* | |
venv/* | ||
packages/blosc-zarr/* | ||
!packages/blosc-zarr/bloscZarrDecompress.js | ||
.changesets/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Compare</title> | ||
<link rel="stylesheet" href="index.css" /> | ||
<script type="module" src="../src/itk-viewer-element.ts"></script> | ||
<script type="module" src="../src/itk-viewport.ts"></script> | ||
<script type="module" src="../src/itk-view-2d.ts"></script> | ||
<script type="module" src="../src/itk-view-2d-vtkjs.ts"></script> | ||
|
||
<script type="module" src="./compare.ts"></script> | ||
</head> | ||
|
||
<body> | ||
<itk-viewer class="fill" style="flex-direction: row; gap: 0.25rem"> | ||
<itk-viewport class="fill"> | ||
<itk-view-2d class="fill"> | ||
<itk-view-2d-vtkjs></itk-view-2d-vtkjs> | ||
</itk-view-2d> | ||
</itk-viewport> | ||
<itk-viewport class="fill"> | ||
<itk-view-2d class="fill"> | ||
<itk-view-2d-vtkjs></itk-view-2d-vtkjs> | ||
</itk-view-2d> | ||
</itk-viewport> | ||
</itk-viewer> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { ZarrMultiscaleSpatialImage } from '@itk-viewer/io/ZarrMultiscaleSpatialImage.js'; | ||
import { setPipelineWorkerUrl, setPipelinesBaseUrl } from 'itk-wasm'; | ||
|
||
const pipelineWorkerUrl = '/itk/web-workers/itk-wasm-pipeline.min.worker.js'; | ||
setPipelineWorkerUrl(pipelineWorkerUrl); | ||
const pipelineBaseUrl = '/itk/pipelines'; | ||
setPipelinesBaseUrl(pipelineBaseUrl); | ||
|
||
document.addEventListener('DOMContentLoaded', async function () { | ||
const [v0, v1] = Array.from(document.querySelectorAll('itk-viewport')).map( | ||
(el) => el.getActor(), | ||
); | ||
const camera = v0?.getSnapshot()?.context?.camera; | ||
if (!camera) throw new Error('Could not get camera'); | ||
v1?.send({ type: 'setCamera', camera }); | ||
|
||
const imagePath = '/ome-ngff-prototypes/single_image/v0.4/zyx.ome.zarr'; | ||
const url = new URL(imagePath, document.location.origin); | ||
const image = await ZarrMultiscaleSpatialImage.fromUrl(url); | ||
|
||
const viewerElement = document.querySelector('itk-viewer'); | ||
if (!viewerElement) throw new Error('Could not find element'); | ||
const viewer = viewerElement.getActor(); | ||
viewer.send({ type: 'setImage', image, name: 'image' }); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
export type Bounds = [number, number, number, number, number, number]; | ||
|
||
export type ReadonlyBounds = readonly [ | ||
number, | ||
number, | ||
number, | ||
number, | ||
number, | ||
number, | ||
]; | ||
|
||
const INIT_BOUNDS = Object.freeze([ | ||
Number.MAX_VALUE, | ||
-Number.MAX_VALUE, // X | ||
Number.MAX_VALUE, | ||
-Number.MAX_VALUE, // Y | ||
Number.MAX_VALUE, | ||
-Number.MAX_VALUE, // Z | ||
] as ReadonlyBounds); | ||
|
||
export const createBounds = () => [...INIT_BOUNDS] as Bounds; | ||
|
||
export function addPoint(bounds: Bounds, x: number, y: number, z: number) { | ||
const [xMin, xMax, yMin, yMax, zMin, zMax] = bounds; | ||
bounds[0] = xMin < x ? xMin : x; | ||
bounds[1] = xMax > x ? xMax : x; | ||
bounds[2] = yMin < y ? yMin : y; | ||
bounds[3] = yMax > y ? yMax : y; | ||
bounds[4] = zMin < z ? zMin : z; | ||
bounds[5] = zMax > z ? zMax : z; | ||
return bounds; | ||
} | ||
|
||
export function getCorners(bounds: ReadonlyBounds) { | ||
const corners = new Array<[number, number, number]>(8); | ||
let count = 0; | ||
for (let ix = 0; ix < 2; ix++) { | ||
for (let iy = 2; iy < 4; iy++) { | ||
for (let iz = 4; iz < 6; iz++) { | ||
corners[count++] = [bounds[ix], bounds[iy], bounds[iz]]; | ||
} | ||
} | ||
} | ||
return corners; | ||
} | ||
|
||
export function getLength(bounds: ReadonlyBounds, index: number) { | ||
return bounds[index * 2 + 1] - bounds[index * 2]; | ||
} |
File renamed without changes.
File renamed without changes.
Oops, something went wrong.