2024-03-22 16:55:30 +11:00
|
|
|
import { SceneEntities } from 'clientSideScene/sceneEntities'
|
|
|
|
import { SceneInfra } from 'clientSideScene/sceneInfra'
|
2024-04-19 14:24:40 -07:00
|
|
|
import EditorManager from 'editor/manager'
|
2024-03-22 16:55:30 +11:00
|
|
|
import { KclManager } from 'lang/KclSingleton'
|
2024-04-17 20:18:07 -07:00
|
|
|
import CodeManager from 'lang/codeManager'
|
2024-03-22 16:55:30 +11:00
|
|
|
import { EngineCommandManager } from 'lang/std/engineConnection'
|
2025-04-01 14:20:42 -07:00
|
|
|
import { uuidv4 } from './utils'
|
2025-04-01 15:31:19 -07:00
|
|
|
import RustContext from 'lib/rustContext'
|
2025-04-01 14:20:42 -07:00
|
|
|
|
2024-04-17 20:18:07 -07:00
|
|
|
export const codeManager = new CodeManager()
|
|
|
|
|
2024-03-22 16:55:30 +11:00
|
|
|
export const engineCommandManager = new EngineCommandManager()
|
|
|
|
|
2025-03-13 10:54:00 -04:00
|
|
|
declare global {
|
|
|
|
interface Window {
|
|
|
|
editorManager: EditorManager
|
|
|
|
engineCommandManager: EngineCommandManager
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-07-07 13:10:52 -04:00
|
|
|
// Accessible for tests mostly
|
2025-03-13 10:54:00 -04:00
|
|
|
window.engineCommandManager = engineCommandManager
|
2024-07-07 13:10:52 -04:00
|
|
|
|
2024-04-19 14:24:40 -07:00
|
|
|
// This needs to be after codeManager is created.
|
2024-03-22 16:55:30 +11:00
|
|
|
export const kclManager = new KclManager(engineCommandManager)
|
2024-08-30 05:14:24 -05:00
|
|
|
engineCommandManager.kclManager = kclManager
|
2024-07-04 01:40:45 -04:00
|
|
|
|
2024-03-22 16:55:30 +11:00
|
|
|
export const sceneInfra = new SceneInfra(engineCommandManager)
|
|
|
|
engineCommandManager.camControlsCameraChange = sceneInfra.onCameraChange
|
|
|
|
|
|
|
|
export const sceneEntitiesManager = new SceneEntities(engineCommandManager)
|
2024-04-19 14:24:40 -07:00
|
|
|
|
|
|
|
// This needs to be after sceneInfra and engineCommandManager are is created.
|
|
|
|
export const editorManager = new EditorManager()
|
2024-04-22 20:14:06 +10:00
|
|
|
|
2025-03-15 10:08:39 -07:00
|
|
|
export const rustContext = new RustContext(engineCommandManager)
|
|
|
|
|
2024-04-22 20:14:06 +10:00
|
|
|
if (typeof window !== 'undefined') {
|
|
|
|
;(window as any).engineCommandManager = engineCommandManager
|
|
|
|
;(window as any).kclManager = kclManager
|
|
|
|
;(window as any).sceneInfra = sceneInfra
|
|
|
|
;(window as any).sceneEntitiesManager = sceneEntitiesManager
|
|
|
|
;(window as any).editorManager = editorManager
|
2025-03-15 10:08:39 -07:00
|
|
|
;(window as any).codeManager = codeManager
|
|
|
|
;(window as any).rustContext = rustContext
|
2024-04-22 20:14:06 +10:00
|
|
|
;(window as any).enableMousePositionLogs = () =>
|
|
|
|
document.addEventListener('mousemove', (e) =>
|
|
|
|
console.log(`await page.mouse.click(${e.clientX}, ${e.clientY})`)
|
|
|
|
)
|
2024-07-15 19:20:32 +10:00
|
|
|
;(window as any).enableFillet = () => {
|
|
|
|
;(window as any)._enableFillet = true
|
|
|
|
}
|
2024-08-05 16:08:30 +10:00
|
|
|
;(window as any).zoomToFit = () =>
|
|
|
|
engineCommandManager.sendSceneCommand({
|
|
|
|
type: 'modeling_cmd_req',
|
|
|
|
cmd_id: uuidv4(),
|
|
|
|
cmd: {
|
|
|
|
type: 'zoom_to_fit',
|
|
|
|
object_ids: [], // leave empty to zoom to all objects
|
|
|
|
padding: 0.2, // padding around the objects
|
2024-10-04 13:47:44 -07:00
|
|
|
animated: false, // don't animate the zoom for now
|
2024-08-05 16:08:30 +10:00
|
|
|
},
|
|
|
|
})
|
2024-04-22 20:14:06 +10:00
|
|
|
}
|