Fix another cyclic mfer!

This commit is contained in:
lee-at-zoo-corp
2025-04-03 15:10:23 -04:00
parent 3471f73479
commit 91b5549a06
4 changed files with 12 additions and 4 deletions

View File

@ -31,6 +31,7 @@ import {
codeManager,
engineCommandManager,
rustContext,
sceneInfra,
} from '@src/lib/singletons'
import { maybeWriteToDisk } from '@src/lib/telemetry'
import { type IndexLoaderData } from '@src/lib/types'
@ -39,6 +40,9 @@ import { EngineStreamTransition } from '@src/machines/engineStreamMachine'
import { commandBarActor } from '@src/machines/commandBarMachine'
import { onboardingPaths } from '@src/routes/Onboarding/paths'
// CYCLIC REF
sceneInfra.camControls.engineStreamActor = engineStreamActor
maybeWriteToDisk()
.then(() => {})
.catch(() => {})

View File

@ -1,3 +1,4 @@
import type { EngineStreamActor } from '@src/machines/engineStreamMachine'
import type { CameraViewState_type, CameraDragInteractionType_type } from '@kittycad/lib/dist/types/src/models'
import * as TWEEN from '@tweenjs/tween.js'
import {
@ -39,7 +40,6 @@ import {
uuidv4,
} from '@src/lib/utils'
import { deg2Rad } from '@src/lib/utils2d'
import { engineStreamActor } from '@src/machines/appMachine'
const ORTHOGRAPHIC_CAMERA_SIZE = 20
const FRAMES_TO_ANIMATE_IN = 30
@ -98,6 +98,7 @@ class CameraRateLimiter {
export class CameraControls {
engineCommandManager: EngineCommandManager
engineStreamActor?: EngineStreamActor
syncDirection: 'clientToEngine' | 'engineToClient' = 'engineToClient'
camera: PerspectiveCamera | OrthographicCamera
target: Vector3
@ -471,9 +472,9 @@ export class CameraControls {
if (this.syncDirection === 'engineToClient') {
const newCmdId = uuidv4()
const { videoRef } = engineStreamActor.getSnapshot().context
const videoRef = this.engineStreamActor?.getSnapshot().context.videoRef
// Nonsense to do anything until the video stream is established.
if (!videoRef.current) return
if (!videoRef?.current) return
const { x, y } = getNormalisedCoordinates(
event,

View File

@ -41,6 +41,7 @@ export const kclManager = new KclManager(engineCommandManager, {
// The most obvious of cyclic dependencies.
// This is because the handleOnViewUpdate(viewUpdate: ViewUpdate): void {
// method requires it for the current ast.
// CYCLIC REF
editorManager.kclManager = kclManager
engineCommandManager.kclManager = kclManager

View File

@ -1,6 +1,6 @@
import { jsAppSettings } from '@src/lib/settings/settingsUtils'
import type { MutableRefObject } from 'react'
import { setup, assign, fromPromise } from 'xstate'
import { setup, assign, fromPromise, ActorRefFrom } from 'xstate'
import {
rustContext,
kclManager,
@ -317,3 +317,5 @@ export const engineStreamMachine = setup({
},
},
})
export type EngineStreamActor = ActorRefFrom<typeof engineStreamMachine>