Skip to content

Commit

Permalink
fix(web): AO invariant error
Browse files Browse the repository at this point in the history
  • Loading branch information
keiya01 committed Jul 12, 2023
1 parent 4ec0bc6 commit b1875e6
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { PerspectiveFrustum, type Scene, Math as CesiumMath } from "@cesium/engine";
import { useState, type FC } from "react";
import { useCesium } from "resium";
import invariant from "tiny-invariant";

import { useInstance } from "../../hooks/useInstance";
import { usePreRender } from "../../hooks/useSceneEvent";
Expand Down Expand Up @@ -84,10 +83,11 @@ export const AmbientOcclusionStage = ({

usePreRender(() => {
const frustum = scene?.camera.frustum;
invariant(frustum instanceof PerspectiveFrustum);
const cotFovy = 1 / Math.tan(frustum.fovy / 2);
stage.uniforms.focalLength.x = cotFovy * frustum.aspectRatio;
stage.uniforms.focalLength.y = cotFovy;
if (frustum instanceof PerspectiveFrustum) {
const cotFovy = 1 / Math.tan(frustum.fovy / 2);
stage.uniforms.focalLength.x = cotFovy * frustum.aspectRatio;
stage.uniforms.focalLength.y = cotFovy;
}
});

return null;
Expand Down

0 comments on commit b1875e6

Please sign in to comment.