Skip to content

Commit c9ea540

Browse files
zaloclaude
andcommitted
Fit camera to model bounding box on first render
Center the orbit controls target on the model's bounding box after the initial evaluation so the default view frames the starter model instead of orbiting the hardcoded origin. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 11d05f9 commit c9ea540

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

js/MainPage/CascadeView.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ class CascadeEnvironment {
134134
this._historyPending = false; // True while awaiting worker mesh response
135135
this._lastSceneOptions = {};
136136

137+
// Fit camera on first render so the orbit target centers on the model
138+
this._isFirstRender = true;
139+
137140
// Register the shape rendering callback
138141
this._registerRenderCallback(messageBus);
139142

@@ -395,6 +398,10 @@ class CascadeEnvironment {
395398
}
396399

397400
this.environment.scene.add(this.mainObject);
401+
if (this._isFirstRender) {
402+
this._isFirstRender = false;
403+
this.fitCamera();
404+
}
398405
this.environment.viewDirty = true;
399406
console.log("Generation Complete!");
400407
});

0 commit comments

Comments
 (0)