zoom to fit on load (#2201)

* zoom to fit on load

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* lint

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* add zoom to fit calls to the correct places

* update comment

* clean up comment

* add snapshot test zoom to git

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)

* subscribe to camera updates from zoom to fit

* fix types

* partial test fix

* updatges

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fix another test

* remove my enhancements

Signed-off-by: Jess Frazelle <github@jessfraz.com>

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
Co-authored-by: Kurt Hutten Irev-Dev <k.hutten@protonmail.ch>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
Jess Frazelle
2024-05-23 17:05:54 -07:00
committed by GitHub
parent 4be63e7331
commit 87979b17cf
11 changed files with 198 additions and 59 deletions

View File

@ -1132,10 +1132,26 @@ export class EngineCommandManager {
},
})
this.initPlanes().then(() => {
this.initPlanes().then(async () => {
this.resolveReady()
setIsStreamReady(true)
executeCode()
await executeCode()
await this.sendSceneCommand({
type: 'modeling_cmd_req',
cmd_id: uuidv4(),
cmd: {
type: 'zoom_to_fit',
object_ids: [], // leave empty to zoom to all objects
padding: 0.1, // padding around the objects
},
})
// make sure client camera syncs after zoom to fit since zoom to fit doesn't return camera settings
// TODO: https://github.com/KittyCAD/engine/issues/2098
await this.sendSceneCommand({
type: 'modeling_cmd_req',
cmd_id: uuidv4(),
cmd: { type: 'default_camera_get_settings' },
})
})
},
onClose: () => {