@itk-viewer/viewer
Advanced tools
Comparing version 0.2.2 to 0.2.3
# @itk-viewer/viewer | ||
## 0.2.3 | ||
### Patch Changes | ||
- 6191b9a: Change remote image scale based on fpsWatcher. Includes image memory size check. | ||
- Updated dependencies [6191b9a] | ||
- @itk-viewer/io@0.1.3 | ||
## 0.2.2 | ||
@@ -4,0 +12,0 @@ |
@@ -7,5 +7,6 @@ import { ReadonlyMat4, ReadonlyVec3 } from 'gl-matrix'; | ||
}; | ||
type context = { | ||
type Context = { | ||
pose: ReadonlyMat4; | ||
lookAt: LookAtParams; | ||
verticalFieldOfView: number; | ||
}; | ||
@@ -20,4 +21,4 @@ type SetPoseEvent = { | ||
}; | ||
export declare const createCamera: () => import("xstate").Actor<import("xstate").StateMachine<context, SetPoseEvent | LookAtEvent, import("xstate").ProvidedActor, import("xstate").ParameterizedObject, import("xstate").ParameterizedObject, any, import("xstate").NonReducibleUnknown, import("xstate").ResolveTypegenMeta<import("xstate").TypegenDisabled, SetPoseEvent | LookAtEvent, import("xstate").ProvidedActor, import("xstate").ParameterizedObject, import("xstate").ParameterizedObject>>, SetPoseEvent | LookAtEvent>; | ||
export declare const createCamera: () => import("xstate").Actor<import("xstate").StateMachine<Context, SetPoseEvent | LookAtEvent, import("xstate").ProvidedActor, import("xstate").ParameterizedObject, import("xstate").ParameterizedObject, any, import("xstate").NonReducibleUnknown, import("xstate").ResolveTypegenMeta<import("xstate").TypegenDisabled, SetPoseEvent | LookAtEvent, import("xstate").ProvidedActor, import("xstate").ParameterizedObject, import("xstate").ParameterizedObject>>, SetPoseEvent | LookAtEvent>; | ||
export type Camera = ReturnType<typeof createCamera>; | ||
export {}; |
@@ -10,2 +10,3 @@ import { mat4 } from 'gl-matrix'; | ||
lookAt: { eye: [0, 0, 0], target: [0, 0, 1], up: [0, 1, 0] }, | ||
verticalFieldOfView: 50, | ||
}, | ||
@@ -12,0 +13,0 @@ states: { |
@@ -5,3 +5,3 @@ /// <reference types="gl-matrix/index.js" /> | ||
type: "setImage"; | ||
image: import("@itk-viewer/io/MultiscaleSpatialImage.js").default; | ||
image: import("@itk-viewer/io/MultiscaleSpatialImage.js").MultiscaleSpatialImage; | ||
} | { | ||
@@ -12,2 +12,3 @@ type: "setCamera"; | ||
lookAt: import("./camera-machine.js").LookAtParams; | ||
verticalFieldOfView: number; | ||
}, { | ||
@@ -36,6 +37,7 @@ type: "setPose"; | ||
}, import("xstate").State<{ | ||
image: import("@itk-viewer/io/MultiscaleSpatialImage.js").default | undefined; | ||
image: import("@itk-viewer/io/MultiscaleSpatialImage.js").MultiscaleSpatialImage | undefined; | ||
camera?: import("xstate").Actor<import("xstate").StateMachine<{ | ||
pose: import("gl-matrix").ReadonlyMat4; | ||
lookAt: import("./camera-machine.js").LookAtParams; | ||
verticalFieldOfView: number; | ||
}, { | ||
@@ -63,3 +65,3 @@ type: "setPose"; | ||
type: "setImage"; | ||
image: import("@itk-viewer/io/MultiscaleSpatialImage.js").default; | ||
image: import("@itk-viewer/io/MultiscaleSpatialImage.js").MultiscaleSpatialImage; | ||
} | { | ||
@@ -70,2 +72,3 @@ type: "setCamera"; | ||
lookAt: import("./camera-machine.js").LookAtParams; | ||
verticalFieldOfView: number; | ||
}, { | ||
@@ -95,3 +98,3 @@ type: "setPose"; | ||
type: "setImage"; | ||
image: import("@itk-viewer/io/MultiscaleSpatialImage.js").default; | ||
image: import("@itk-viewer/io/MultiscaleSpatialImage.js").MultiscaleSpatialImage; | ||
} | { | ||
@@ -102,2 +105,3 @@ type: "setCamera"; | ||
lookAt: import("./camera-machine.js").LookAtParams; | ||
verticalFieldOfView: number; | ||
}, { | ||
@@ -126,3 +130,3 @@ type: "setPose"; | ||
}, import("xstate").ProvidedActor, import("xstate").ParameterizedObject, import("xstate").ParameterizedObject>>>>; | ||
images: Record<string, import("@itk-viewer/io/MultiscaleSpatialImage.js").default>; | ||
images: Record<string, import("@itk-viewer/io/MultiscaleSpatialImage.js").MultiscaleSpatialImage>; | ||
}, { | ||
@@ -133,3 +137,3 @@ type: "addViewport"; | ||
type: "setImage"; | ||
image: import("@itk-viewer/io/MultiscaleSpatialImage.js").default; | ||
image: import("@itk-viewer/io/MultiscaleSpatialImage.js").MultiscaleSpatialImage; | ||
} | { | ||
@@ -140,2 +144,3 @@ type: "setCamera"; | ||
lookAt: import("./camera-machine.js").LookAtParams; | ||
verticalFieldOfView: number; | ||
}, { | ||
@@ -164,6 +169,7 @@ type: "setPose"; | ||
}, import("xstate").State<{ | ||
image: import("@itk-viewer/io/MultiscaleSpatialImage.js").default | undefined; | ||
image: import("@itk-viewer/io/MultiscaleSpatialImage.js").MultiscaleSpatialImage | undefined; | ||
camera?: import("xstate").Actor<import("xstate").StateMachine<{ | ||
pose: import("gl-matrix").ReadonlyMat4; | ||
lookAt: import("./camera-machine.js").LookAtParams; | ||
verticalFieldOfView: number; | ||
}, { | ||
@@ -191,3 +197,3 @@ type: "setPose"; | ||
type: "setImage"; | ||
image: import("@itk-viewer/io/MultiscaleSpatialImage.js").default; | ||
image: import("@itk-viewer/io/MultiscaleSpatialImage.js").MultiscaleSpatialImage; | ||
} | { | ||
@@ -198,2 +204,3 @@ type: "setCamera"; | ||
lookAt: import("./camera-machine.js").LookAtParams; | ||
verticalFieldOfView: number; | ||
}, { | ||
@@ -223,3 +230,3 @@ type: "setPose"; | ||
type: "setImage"; | ||
image: import("@itk-viewer/io/MultiscaleSpatialImage.js").default; | ||
image: import("@itk-viewer/io/MultiscaleSpatialImage.js").MultiscaleSpatialImage; | ||
} | { | ||
@@ -230,2 +237,3 @@ type: "setCamera"; | ||
lookAt: import("./camera-machine.js").LookAtParams; | ||
verticalFieldOfView: number; | ||
}, { | ||
@@ -257,3 +265,3 @@ type: "setPose"; | ||
name: string; | ||
image: import("@itk-viewer/io/MultiscaleSpatialImage.js").default; | ||
image: import("@itk-viewer/io/MultiscaleSpatialImage.js").MultiscaleSpatialImage; | ||
}, import("xstate").ProvidedActor, import("xstate").ParameterizedObject, import("xstate").ParameterizedObject, any, import("xstate").NonReducibleUnknown, import("xstate").ResolveTypegenMeta<import("xstate").TypegenDisabled, { | ||
@@ -264,3 +272,3 @@ type: "addViewport"; | ||
type: "setImage"; | ||
image: import("@itk-viewer/io/MultiscaleSpatialImage.js").default; | ||
image: import("@itk-viewer/io/MultiscaleSpatialImage.js").MultiscaleSpatialImage; | ||
} | { | ||
@@ -271,2 +279,3 @@ type: "setCamera"; | ||
lookAt: import("./camera-machine.js").LookAtParams; | ||
verticalFieldOfView: number; | ||
}, { | ||
@@ -295,6 +304,7 @@ type: "setPose"; | ||
}, import("xstate").State<{ | ||
image: import("@itk-viewer/io/MultiscaleSpatialImage.js").default | undefined; | ||
image: import("@itk-viewer/io/MultiscaleSpatialImage.js").MultiscaleSpatialImage | undefined; | ||
camera?: import("xstate").Actor<import("xstate").StateMachine<{ | ||
pose: import("gl-matrix").ReadonlyMat4; | ||
lookAt: import("./camera-machine.js").LookAtParams; | ||
verticalFieldOfView: number; | ||
}, { | ||
@@ -322,3 +332,3 @@ type: "setPose"; | ||
type: "setImage"; | ||
image: import("@itk-viewer/io/MultiscaleSpatialImage.js").default; | ||
image: import("@itk-viewer/io/MultiscaleSpatialImage.js").MultiscaleSpatialImage; | ||
} | { | ||
@@ -329,2 +339,3 @@ type: "setCamera"; | ||
lookAt: import("./camera-machine.js").LookAtParams; | ||
verticalFieldOfView: number; | ||
}, { | ||
@@ -354,3 +365,3 @@ type: "setPose"; | ||
type: "setImage"; | ||
image: import("@itk-viewer/io/MultiscaleSpatialImage.js").default; | ||
image: import("@itk-viewer/io/MultiscaleSpatialImage.js").MultiscaleSpatialImage; | ||
} | { | ||
@@ -361,2 +372,3 @@ type: "setCamera"; | ||
lookAt: import("./camera-machine.js").LookAtParams; | ||
verticalFieldOfView: number; | ||
}, { | ||
@@ -388,3 +400,3 @@ type: "setPose"; | ||
name: string; | ||
image: import("@itk-viewer/io/MultiscaleSpatialImage.js").default; | ||
image: import("@itk-viewer/io/MultiscaleSpatialImage.js").MultiscaleSpatialImage; | ||
}, import("xstate").ProvidedActor, import("xstate").ParameterizedObject, import("xstate").ParameterizedObject>>, { | ||
@@ -395,3 +407,3 @@ type: "addViewport"; | ||
type: "setImage"; | ||
image: import("@itk-viewer/io/MultiscaleSpatialImage.js").default; | ||
image: import("@itk-viewer/io/MultiscaleSpatialImage.js").MultiscaleSpatialImage; | ||
} | { | ||
@@ -402,2 +414,3 @@ type: "setCamera"; | ||
lookAt: import("./camera-machine.js").LookAtParams; | ||
verticalFieldOfView: number; | ||
}, { | ||
@@ -426,6 +439,7 @@ type: "setPose"; | ||
}, import("xstate").State<{ | ||
image: import("@itk-viewer/io/MultiscaleSpatialImage.js").default | undefined; | ||
image: import("@itk-viewer/io/MultiscaleSpatialImage.js").MultiscaleSpatialImage | undefined; | ||
camera?: import("xstate").Actor<import("xstate").StateMachine<{ | ||
pose: import("gl-matrix").ReadonlyMat4; | ||
lookAt: import("./camera-machine.js").LookAtParams; | ||
verticalFieldOfView: number; | ||
}, { | ||
@@ -453,3 +467,3 @@ type: "setPose"; | ||
type: "setImage"; | ||
image: import("@itk-viewer/io/MultiscaleSpatialImage.js").default; | ||
image: import("@itk-viewer/io/MultiscaleSpatialImage.js").MultiscaleSpatialImage; | ||
} | { | ||
@@ -460,2 +474,3 @@ type: "setCamera"; | ||
lookAt: import("./camera-machine.js").LookAtParams; | ||
verticalFieldOfView: number; | ||
}, { | ||
@@ -485,3 +500,3 @@ type: "setPose"; | ||
type: "setImage"; | ||
image: import("@itk-viewer/io/MultiscaleSpatialImage.js").default; | ||
image: import("@itk-viewer/io/MultiscaleSpatialImage.js").MultiscaleSpatialImage; | ||
} | { | ||
@@ -492,2 +507,3 @@ type: "setCamera"; | ||
lookAt: import("./camera-machine.js").LookAtParams; | ||
verticalFieldOfView: number; | ||
}, { | ||
@@ -519,4 +535,4 @@ type: "setPose"; | ||
name: string; | ||
image: import("@itk-viewer/io/MultiscaleSpatialImage.js").default; | ||
image: import("@itk-viewer/io/MultiscaleSpatialImage.js").MultiscaleSpatialImage; | ||
}>; | ||
export type Viewer = ReturnType<typeof createViewer>; |
@@ -58,5 +58,4 @@ import { assign, createMachine, sendParent } from 'xstate'; | ||
return; | ||
const scale = 3; // image.coarsestScale | ||
await image.scaleIndexToWorld(scale); // initializes indexToWorld matrix for getWorldBounds | ||
const bounds = image.getWorldBounds(scale); | ||
const { pose: currentPose, verticalFieldOfView } = camera.getSnapshot().context; | ||
const bounds = await image.getWorldBounds(image.coarsestScale); | ||
const center = vec3.fromValues((bounds[0] + bounds[1]) / 2.0, (bounds[2] + bounds[3]) / 2.0, (bounds[4] + bounds[5]) / 2.0); | ||
@@ -74,5 +73,4 @@ let w1 = bounds[1] - bounds[0]; | ||
radius = Math.sqrt(radius) * 0.5; | ||
const angle = 55 * (Math.PI / 180); // to radians | ||
const angle = verticalFieldOfView * (Math.PI / 180); // to radians | ||
const distance = radius / Math.sin(angle * 0.5); | ||
const currentPose = camera.getSnapshot().context.pose; | ||
const forward = [currentPose[8], currentPose[9], currentPose[10]]; | ||
@@ -79,0 +77,0 @@ const up = vec3.fromValues(currentPose[4], currentPose[5], currentPose[6]); |
/// <reference types="gl-matrix/index.js" /> | ||
export declare const createViewport: () => import("xstate").Actor<import("xstate").StateMachine<{ | ||
image: import("@itk-viewer/io/MultiscaleSpatialImage.js").default | undefined; | ||
image: import("@itk-viewer/io/MultiscaleSpatialImage.js").MultiscaleSpatialImage | undefined; | ||
camera?: import("xstate").Actor<import("xstate").StateMachine<{ | ||
pose: import("gl-matrix").ReadonlyMat4; | ||
lookAt: import("./camera-machine.js").LookAtParams; | ||
verticalFieldOfView: number; | ||
}, { | ||
@@ -29,3 +30,3 @@ type: "setPose"; | ||
type: "setImage"; | ||
image: import("@itk-viewer/io/MultiscaleSpatialImage.js").default; | ||
image: import("@itk-viewer/io/MultiscaleSpatialImage.js").MultiscaleSpatialImage; | ||
} | { | ||
@@ -36,2 +37,3 @@ type: "setCamera"; | ||
lookAt: import("./camera-machine.js").LookAtParams; | ||
verticalFieldOfView: number; | ||
}, { | ||
@@ -61,3 +63,3 @@ type: "setPose"; | ||
type: "setImage"; | ||
image: import("@itk-viewer/io/MultiscaleSpatialImage.js").default; | ||
image: import("@itk-viewer/io/MultiscaleSpatialImage.js").MultiscaleSpatialImage; | ||
} | { | ||
@@ -68,2 +70,3 @@ type: "setCamera"; | ||
lookAt: import("./camera-machine.js").LookAtParams; | ||
verticalFieldOfView: number; | ||
}, { | ||
@@ -93,3 +96,3 @@ type: "setPose"; | ||
type: "setImage"; | ||
image: import("@itk-viewer/io/MultiscaleSpatialImage.js").default; | ||
image: import("@itk-viewer/io/MultiscaleSpatialImage.js").MultiscaleSpatialImage; | ||
} | { | ||
@@ -100,2 +103,3 @@ type: "setCamera"; | ||
lookAt: import("./camera-machine.js").LookAtParams; | ||
verticalFieldOfView: number; | ||
}, { | ||
@@ -102,0 +106,0 @@ type: "setPose"; |
{ | ||
"name": "@itk-viewer/viewer", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"description": "Multi-dimensional web-based image, mesh, and point set viewer", | ||
@@ -46,3 +46,3 @@ "type": "module", | ||
"xstate": "5.0.0-beta.24", | ||
"@itk-viewer/io": "^0.1.2" | ||
"@itk-viewer/io": "^0.1.3" | ||
}, | ||
@@ -49,0 +49,0 @@ "scripts": { |
@@ -10,5 +10,6 @@ import { ReadonlyMat4, ReadonlyVec3, mat4 } from 'gl-matrix'; | ||
type context = { | ||
type Context = { | ||
pose: ReadonlyMat4; | ||
lookAt: LookAtParams; | ||
verticalFieldOfView: number; | ||
}; | ||
@@ -28,3 +29,3 @@ | ||
types: {} as { | ||
context: context; | ||
context: Context; | ||
events: SetPoseEvent | LookAtEvent; | ||
@@ -37,2 +38,3 @@ }, | ||
lookAt: { eye: [0, 0, 0], target: [0, 0, 1], up: [0, 1, 0] }, | ||
verticalFieldOfView: 50, | ||
}, | ||
@@ -39,0 +41,0 @@ states: { |
@@ -96,6 +96,7 @@ import { ActorRef, assign, createMachine, sendParent } from 'xstate'; | ||
const scale = 3; // image.coarsestScale | ||
await image.scaleIndexToWorld(scale); // initializes indexToWorld matrix for getWorldBounds | ||
const bounds = image.getWorldBounds(scale); | ||
const { pose: currentPose, verticalFieldOfView } = | ||
camera.getSnapshot().context; | ||
const bounds = await image.getWorldBounds(image.coarsestScale); | ||
const center = vec3.fromValues( | ||
@@ -119,7 +120,5 @@ (bounds[0] + bounds[1]) / 2.0, | ||
const angle = 55 * (Math.PI / 180); // to radians | ||
const angle = verticalFieldOfView * (Math.PI / 180); // to radians | ||
const distance = radius / Math.sin(angle * 0.5); | ||
const currentPose = camera.getSnapshot().context.pose; | ||
const forward = [currentPose[8], currentPose[9], currentPose[10]]; | ||
@@ -126,0 +125,0 @@ const up = vec3.fromValues( |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
118135
1396
Updated@itk-viewer/io@^0.1.3