|
@@ -77,7 +77,7 @@ interface Canvas3D {
|
|
|
|
|
|
handleResize(): void
|
|
handleResize(): void
|
|
/** Focuses camera on scene's bounding sphere, centered and zoomed. */
|
|
/** Focuses camera on scene's bounding sphere, centered and zoomed. */
|
|
- requestCameraReset(durationMs?: number): void
|
|
|
|
|
|
+ requestCameraReset(options?: { durationMs?: number, snapshot?: Partial<Camera.Snapshot> }): void
|
|
readonly camera: Camera
|
|
readonly camera: Camera
|
|
readonly boundingSphere: Readonly<Sphere3D>
|
|
readonly boundingSphere: Readonly<Sphere3D>
|
|
downloadScreenshot(): void
|
|
downloadScreenshot(): void
|
|
@@ -191,6 +191,7 @@ namespace Canvas3D {
|
|
let drawPending = false
|
|
let drawPending = false
|
|
let cameraResetRequested = false
|
|
let cameraResetRequested = false
|
|
let nextCameraResetDuration: number | undefined = void 0
|
|
let nextCameraResetDuration: number | undefined = void 0
|
|
|
|
+ let nextCameraResetSnapshot: Partial<Camera.Snapshot> | undefined = void 0
|
|
|
|
|
|
function getLoci(pickingId: PickingId) {
|
|
function getLoci(pickingId: PickingId) {
|
|
let loci: Loci = EmptyLoci
|
|
let loci: Loci = EmptyLoci
|
|
@@ -290,9 +291,15 @@ namespace Canvas3D {
|
|
function resolveCameraReset() {
|
|
function resolveCameraReset() {
|
|
if (!cameraResetRequested) return;
|
|
if (!cameraResetRequested) return;
|
|
const { center, radius } = scene.boundingSphere;
|
|
const { center, radius } = scene.boundingSphere;
|
|
- const duration = nextCameraResetDuration === undefined ? p.cameraResetDurationMs : nextCameraResetDuration
|
|
|
|
- camera.focus(center, radius, radius, duration);
|
|
|
|
|
|
+ if (radius >= 0) {
|
|
|
|
+ const duration = nextCameraResetDuration === undefined ? p.cameraResetDurationMs : nextCameraResetDuration
|
|
|
|
+ const focus = camera.getFocus(center, radius, radius);
|
|
|
|
+ const snapshot = nextCameraResetSnapshot ? { ...focus, ...nextCameraResetSnapshot } : focus;
|
|
|
|
+ camera.setState(snapshot, duration);
|
|
|
|
+ }
|
|
|
|
+
|
|
nextCameraResetDuration = void 0;
|
|
nextCameraResetDuration = void 0;
|
|
|
|
+ nextCameraResetSnapshot = void 0;
|
|
cameraResetRequested = false;
|
|
cameraResetRequested = false;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -388,8 +395,9 @@ namespace Canvas3D {
|
|
getLoci,
|
|
getLoci,
|
|
|
|
|
|
handleResize,
|
|
handleResize,
|
|
- requestCameraReset: (durationMs) => {
|
|
|
|
- nextCameraResetDuration = durationMs;
|
|
|
|
|
|
+ requestCameraReset: options => {
|
|
|
|
+ nextCameraResetDuration = options?.durationMs;
|
|
|
|
+ nextCameraResetSnapshot = options?.snapshot;
|
|
cameraResetRequested = true;
|
|
cameraResetRequested = true;
|
|
},
|
|
},
|
|
camera,
|
|
camera,
|