Skip to content

Commit

Permalink
Wind Waker: Fix title demo not respecting camera fov and roll
Browse files Browse the repository at this point in the history
It should be in Cinematic mode, but it does not want letterboxing
  • Loading branch information
themikelester committed Jan 4, 2025
1 parent 7ca9dfe commit 33cf94b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/ZeldaWindWaker/Main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -968,8 +968,7 @@ class DemoDesc extends SceneDesc implements Viewer.SceneDesc {

if (demoData !== null) {
globals.scnPlay.demo.create(this.id, demoData, this.offsetPos, this.rotY / 180.0 * Math.PI, this.startFrame);
if (globals.scnPlay.demo.getName() !== 'title')
globals.camera.snapToCinematic();
globals.camera.snapToCinematic();
} else {
console.warn('Failed to load demo data:', this.stbFilename);
}
Expand Down
7 changes: 5 additions & 2 deletions src/ZeldaWindWaker/d_camera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,19 +125,22 @@ export class dCamera_c extends leafdraw_class {
if (demoCam.flags & EDemoCamFlags.HasNearZ) { this.near = demoCam.projNear; }
if (demoCam.flags & EDemoCamFlags.HasFarZ) { this.far = demoCam.projFar; }

this.cameraMode = (globals.scnPlay.demo.getName() == 'title') ? CameraMode.Default : CameraMode.Cinematic;
this.cameraMode = CameraMode.Cinematic;
globals.sceneContext.inputManager.isMouseEnabled = false;
} else {
this.cameraMode = CameraMode.Default;
globals.sceneContext.inputManager.isMouseEnabled = true;
}

// From dCamera_c::SetTrimSize() and defaultTriming()
const trimSize = globals.scnPlay.demo.getName() != 'title' ? dCamera_c.trimHeightCinematic : 0;

// Adapted from dCamera_c::CalcTrimSize()
// When switching between Cinematic and Regular camera modes (e.g. when pausing a cutscene),
// blend the camera parameters smoothly. This accounts for deltaTime, but still works when paused.
deltaTimeFrames = clamp(deltaTimeFrames, 0.5, 1);
this.cameraModeBlendVal += (this.cameraMode - this.cameraModeBlendVal) * 0.25 * deltaTimeFrames;
this.trimHeight = lerp(0, dCamera_c.trimHeightCinematic, this.cameraModeBlendVal);
this.trimHeight = lerp(0, trimSize, this.cameraModeBlendVal);
this.fovY = lerp(this.fovY, this.demoFov, this.cameraModeBlendVal);
this.roll = lerp(this.roll, this.demoRoll, this.cameraModeBlendVal);

Expand Down

0 comments on commit 33cf94b

Please sign in to comment.