PageScene: strip dead code from SaveManager and Editor

Pure removals, no behavior change. Sets up the SaveManager Deps
refactor in the next commit.

SaveManager:
- Drop unused saveData (the live caller is getSceneJson + saveScene
  which goes through saveSceneState directly).
- Drop unused computeSceneChecksum + checkSumData + the
  computeHashForBrowser helper. Zero callers anywhere.
- Drop the editor.generating_preview = true/false bracket inside
  saveScene. The field has no readers — all the noise about "stop
  control panel from flipping out" is dead with VICCCCCCCCCCCCCCCTORRRRRRRR.

Editor:
- Drop generating_preview field (no readers anywhere).
- Drop current_scene_glb_media_token field + the two writes (no
  readers anywhere; suspected leftover of an older save format).
This commit is contained in:
Tanish Manku committed 2026-05-01 03:38:07 -07:00
1 parent 3681f4faef
commit 8780935b62
2 files changed
-90

No files matched your search

@@ -68,12 +68,10 @@ class Editor {
lastFrameTime: number;
current_scene_media_token: string | null;
current_scene_glb_media_token: string | null;
can_initialize: boolean;
positive_prompt: string;
generating_preview: boolean = false;
// Owns canvas/container DOM refs and the resize cascade.
viewport: ViewportController;
@@ -216,7 +214,6 @@ class Editor {
// Scene State
this.current_scene_media_token = null;
this.current_scene_glb_media_token = null;
this.positive_prompt =
"((masterpiece, best quality, 8K, detailed)), colorful, epic, fantasy, (fox, red fox:1.2), no humans, 1other, ((koi pond)), outdoors, pond, rocks, stones, koi fish, ((watercolor))), lilypad, fish swimming around.";
@@ -396,7 +393,6 @@ class Editor {
// saving state of the scene
this.current_scene_media_token = null;
this.current_scene_glb_media_token = null;
this.cameraController.cam_obj = this.activeScene.get_object_by_name(
this.cameraController.camera_name,
@@ -22,89 +22,6 @@ export class SaveManager {
this.editor = editor;
}
async computeHashForBrowser(data: string): Promise<string> {
// Encode the string data to a Uint8Array
const encoder = new TextEncoder();
const encodedData = encoder.encode(data);
// Compute the hash using the SubtleCrypto.digest method
const hashBuffer = await crypto.subtle.digest("SHA-256", encodedData);
// Convert the ArrayBuffer to a hexadecimal string
const hashArray = Array.from(new Uint8Array(hashBuffer));
const hashHex = hashArray
.map((b) => b.toString(16).padStart(2, "0"))
.join("");
return hashHex;
}
public async computeSceneChecksum(): Promise<string> {
const jsonString = await this.checkSumData();
return this.computeHashForBrowser(jsonString);
}
private async checkSumData(): Promise<string> {
const proxyScene = new StoryTellerProxyScene(
this.editor.version,
this.editor.activeScene,
);
const scene_json = await proxyScene.saveToScene(this.editor.version);
const check_sum_data = {
scene: scene_json,
timeline: "",
camera_data: {
position: this.editor.cameraController.camera?.position,
rotation: this.editor.cameraController.camera?.rotation,
},
};
const jsonString = JSON.stringify(check_sum_data);
return jsonString;
}
// JSON structure should and can return snapshot
public async saveData({
sceneGenerationMetadata,
}: {
sceneTitle: string;
sceneToken?: string;
sceneGenerationMetadata: SceneGenereationMetaData;
}): Promise<string> {
const proxyScene = new StoryTellerProxyScene(
this.editor.version,
this.editor.activeScene,
);
const scene_json = await proxyScene.saveToScene(this.editor.version);
const sceneState = usePageSceneStore.getState();
const camerasData = sceneState.cameras.map((cam: Camera) => ({
id: cam.id,
label: cam.label,
focalLength: cam.focalLength,
position: cam.position,
rotation: cam.rotation,
lookAt: cam.lookAt,
}));
const save_data = {
version: this.editor.version,
scene: scene_json,
...sceneGenerationMetadata,
timeline: "",
skybox: this.editor.activeScene.skybox,
camera_data: {
position: this.editor.cameraController.camera?.position,
rotation: this.editor.cameraController.camera?.rotation,
},
cameras: camerasData,
selectedCameraId: sceneState.selectedCameraId,
};
// take json scene and figure out checksum
const jsonString = JSON.stringify(save_data);
return jsonString;
}
public getSceneJson({
sceneGenerationMetadata,
}: {
@@ -154,7 +71,6 @@ export class SaveManager {
sceneToken?: string;
sceneGenerationMetadata: SceneGenereationMetaData;
}): Promise<string> {
this.editor.generating_preview = true; // Set this to true to stop control panel from flipping out.
// remove controls when saving scene.
this.editor.utils.removeTransformControls();
showEditorLoader();
@@ -184,8 +100,6 @@ export class SaveManager {
hideEditorLoader();
this.editor.generating_preview = false; // FIX THIS LATER WITH VICCCCCCCCCCCCCCCTORRRRRRRR
console.debug("Save Scene Result: ", result);
return result; // if this is an empty string it is an error. need to migrate to api manager.
}