[Fix]: When loading the modeling page the user's settings for camera projection was ignored (#7111)
* fix: initialization of user camera projection is now used again, ope * fix: removing comment
This commit is contained in:
@ -1,6 +1,11 @@
|
|||||||
import { DEFAULT_DEFAULT_LENGTH_UNIT } from '@src/lib/constants'
|
import { DEFAULT_DEFAULT_LENGTH_UNIT } from '@src/lib/constants'
|
||||||
import { isPlaywright } from '@src/lib/isPlaywright'
|
import { isPlaywright } from '@src/lib/isPlaywright'
|
||||||
import { engineCommandManager, kclManager } from '@src/lib/singletons'
|
import {
|
||||||
|
engineCommandManager,
|
||||||
|
kclManager,
|
||||||
|
sceneInfra,
|
||||||
|
settingsActor,
|
||||||
|
} from '@src/lib/singletons'
|
||||||
import {
|
import {
|
||||||
engineStreamZoomToFit,
|
engineStreamZoomToFit,
|
||||||
engineViewIsometricWithoutGeometryPresent,
|
engineViewIsometricWithoutGeometryPresent,
|
||||||
@ -22,6 +27,15 @@ export async function resetCameraPosition() {
|
|||||||
if (isPlaywright()) {
|
if (isPlaywright()) {
|
||||||
await engineStreamZoomToFit({ engineCommandManager, padding })
|
await engineStreamZoomToFit({ engineCommandManager, padding })
|
||||||
} else {
|
} else {
|
||||||
|
// Get user camera projection
|
||||||
|
const cameraProjection =
|
||||||
|
settingsActor.getSnapshot().context.modeling.cameraProjection.current
|
||||||
|
|
||||||
|
// We need to keep the users projection setting when resetting their camera
|
||||||
|
if (cameraProjection === 'perspective') {
|
||||||
|
await sceneInfra.camControls.usePerspectiveCamera()
|
||||||
|
}
|
||||||
|
|
||||||
// If the scene is empty you cannot use view_isometric, it will not move the camera
|
// If the scene is empty you cannot use view_isometric, it will not move the camera
|
||||||
if (kclManager.isAstBodyEmpty(kclManager.ast)) {
|
if (kclManager.isAstBodyEmpty(kclManager.ast)) {
|
||||||
await engineViewIsometricWithoutGeometryPresent({
|
await engineViewIsometricWithoutGeometryPresent({
|
||||||
@ -29,6 +43,7 @@ export async function resetCameraPosition() {
|
|||||||
unit:
|
unit:
|
||||||
kclManager.fileSettings.defaultLengthUnit ||
|
kclManager.fileSettings.defaultLengthUnit ||
|
||||||
DEFAULT_DEFAULT_LENGTH_UNIT,
|
DEFAULT_DEFAULT_LENGTH_UNIT,
|
||||||
|
cameraProjection,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
await engineViewIsometricWithGeometryPresent({
|
await engineViewIsometricWithGeometryPresent({
|
||||||
|
@ -12,6 +12,7 @@ import type {
|
|||||||
CameraViewState_type,
|
CameraViewState_type,
|
||||||
UnitLength_type,
|
UnitLength_type,
|
||||||
} from '@kittycad/lib/dist/types/src/models'
|
} from '@kittycad/lib/dist/types/src/models'
|
||||||
|
import type { CameraProjectionType } from '@rust/kcl-lib/bindings/CameraProjectionType'
|
||||||
|
|
||||||
export const uuidv4 = v4
|
export const uuidv4 = v4
|
||||||
|
|
||||||
@ -622,9 +623,11 @@ export async function engineViewIsometricWithGeometryPresent({
|
|||||||
export async function engineViewIsometricWithoutGeometryPresent({
|
export async function engineViewIsometricWithoutGeometryPresent({
|
||||||
engineCommandManager,
|
engineCommandManager,
|
||||||
unit,
|
unit,
|
||||||
|
cameraProjection,
|
||||||
}: {
|
}: {
|
||||||
engineCommandManager: EngineCommandManager
|
engineCommandManager: EngineCommandManager
|
||||||
unit?: UnitLength_type
|
unit?: UnitLength_type
|
||||||
|
cameraProjection: CameraProjectionType
|
||||||
}) {
|
}) {
|
||||||
// If you load an empty scene with any file unit it will have an eye offset of this
|
// If you load an empty scene with any file unit it will have an eye offset of this
|
||||||
const MAGIC_ENGINE_EYE_OFFSET = 1378.0057
|
const MAGIC_ENGINE_EYE_OFFSET = 1378.0057
|
||||||
@ -644,8 +647,8 @@ export async function engineViewIsometricWithoutGeometryPresent({
|
|||||||
eye_offset: MAGIC_ENGINE_EYE_OFFSET,
|
eye_offset: MAGIC_ENGINE_EYE_OFFSET,
|
||||||
fov_y: 45,
|
fov_y: 45,
|
||||||
ortho_scale_factor: 1.4063792,
|
ortho_scale_factor: 1.4063792,
|
||||||
is_ortho: true,
|
is_ortho: cameraProjection !== 'perspective',
|
||||||
ortho_scale_enabled: true,
|
ortho_scale_enabled: cameraProjection !== 'perspective',
|
||||||
world_coord_system: 'right_handed_up_z',
|
world_coord_system: 'right_handed_up_z',
|
||||||
}
|
}
|
||||||
await engineCommandManager.sendSceneCommand({
|
await engineCommandManager.sendSceneCommand({
|
||||||
|
Reference in New Issue
Block a user