Skip to content

Commit

Permalink
Adding requested changes to skybox to utlize useTheme() method from T…
Browse files Browse the repository at this point in the history
…hemeContext

avoiding the use of 'any'
  • Loading branch information
Dhruv-0-Arora committed Jun 28, 2024
1 parent 383cea2 commit f302667
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
9 changes: 6 additions & 3 deletions fission/src/systems/scene/SceneRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class SceneRenderer extends WorldSystem {
ground.castShadow = true;
this._scene.add(ground);

// skybox
// Adding spherical skybox mesh
const geometry = new THREE.SphereGeometry(1000);
const material = new THREE.ShaderMaterial({
vertexShader: vertexShader,
Expand All @@ -92,8 +92,6 @@ class SceneRenderer extends WorldSystem {
bColor: { value: 1.0 },
}
});


this._skybox = new THREE.Mesh(geometry, material);
this._skybox.receiveShadow = false;
this._skybox.castShadow = false;
Expand Down Expand Up @@ -164,6 +162,11 @@ class SceneRenderer extends WorldSystem {
})
}

/*
* Updates the skybox colors based on the current theme
* @param currentTheme: current theme from ThemeContext.useTheme()
*/
public updateSkyboxColors(currentTheme: Theme) {
if (!this._skybox) return;
if (this._skybox.material instanceof THREE.ShaderMaterial) {
Expand Down
7 changes: 3 additions & 4 deletions fission/src/ui/components/Skybox.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/* eslint-disable @typescript-eslint/no-explicit-any */

import World from "@/systems/World";
import { useTheme } from "../ThemeContext";

const Skybox = () => {
const currentTheme = (window as any).getTheme();
if (World.SceneRenderer) { World.SceneRenderer.updateSkyboxColors(currentTheme); }
const { currentTheme, themes } = useTheme();
if (World.SceneRenderer) { World.SceneRenderer.updateSkyboxColors(themes[currentTheme]) }
return (
<></>
);
Expand Down

0 comments on commit f302667

Please sign in to comment.