mirror of
https://github.com/DustinBrett/daedalOS.git
synced 2025-12-06 12:20:20 +01:00
Added landscape wallpaper
This commit is contained in:
parent
2249f2aae0
commit
75e5efd96e
|
|
@ -0,0 +1,30 @@
|
|||
import { loadFiles } from "utils/functions";
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
effectInit: (canvas: HTMLCanvasElement) => void;
|
||||
}
|
||||
}
|
||||
|
||||
export const libs = [
|
||||
"/System/ShaderToy/CoastalLandscape/piLibs.js",
|
||||
"/System/ShaderToy/CoastalLandscape/effect.js",
|
||||
"/System/ShaderToy/CoastalLandscape/init.js",
|
||||
];
|
||||
|
||||
const CoastalLandscape = async (el?: HTMLElement | null): Promise<void> => {
|
||||
if (!el) return;
|
||||
|
||||
await loadFiles(libs);
|
||||
|
||||
const canvas = document.createElement("canvas");
|
||||
|
||||
canvas.height = window.innerHeight;
|
||||
canvas.width = window.innerWidth;
|
||||
|
||||
window.effectInit(canvas);
|
||||
|
||||
el.appendChild(canvas);
|
||||
};
|
||||
|
||||
export default CoastalLandscape;
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
import { libs } from "components/system/Desktop/Wallpapers/ShaderToy/CoastalLandscape";
|
||||
import type { OffscreenRenderProps } from "components/system/Desktop/Wallpapers/types";
|
||||
import { isWebGLAvailable } from "utils/functions";
|
||||
|
||||
/* eslint-disable vars-on-top, no-var */
|
||||
declare global {
|
||||
var effectInit: (canvas: OffscreenCanvas) => void;
|
||||
var updateLandscapeSize: () => void;
|
||||
var demoCanvasRect: DOMRect;
|
||||
var devicePixelRatio: number;
|
||||
}
|
||||
/* eslint-enable vars-on-top, no-var */
|
||||
|
||||
globalThis.addEventListener(
|
||||
"message",
|
||||
({ data }: { data: DOMRect | OffscreenRenderProps | string }) => {
|
||||
if (!isWebGLAvailable) return;
|
||||
|
||||
if (data === "init") {
|
||||
globalThis.importScripts(...libs);
|
||||
} else if (data instanceof DOMRect) {
|
||||
globalThis.demoCanvasRect = data;
|
||||
globalThis.updateLandscapeSize();
|
||||
} else {
|
||||
const { canvas, devicePixelRatio } = data as OffscreenRenderProps;
|
||||
|
||||
globalThis.devicePixelRatio = devicePixelRatio;
|
||||
|
||||
globalThis.effectInit(canvas);
|
||||
}
|
||||
},
|
||||
{ passive: true }
|
||||
);
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
import hexells from "components/system/Desktop/Wallpapers/hexells";
|
||||
import coastalLandscape from "components/system/Desktop/Wallpapers/ShaderToy/CoastalLandscape";
|
||||
import vantaWaves from "components/system/Desktop/Wallpapers/vantaWaves";
|
||||
import { config } from "components/system/Desktop/Wallpapers/vantaWaves/config";
|
||||
import { useFileSystem } from "contexts/fileSystem";
|
||||
|
|
@ -29,6 +30,14 @@ const cssFit: Record<WallpaperFit, string> = {
|
|||
};
|
||||
|
||||
const WALLPAPER_WORKERS: Record<string, () => Worker> = {
|
||||
COASTAL_LANDSCAPE: (): Worker =>
|
||||
new Worker(
|
||||
new URL(
|
||||
"components/system/Desktop/Wallpapers/ShaderToy/CoastalLandscape/wallpaper.worker",
|
||||
import.meta.url
|
||||
),
|
||||
{ name: "Wallpaper (Coastal Landscape)" }
|
||||
),
|
||||
HEXELLS: (): Worker =>
|
||||
new Worker(
|
||||
new URL(
|
||||
|
|
@ -83,6 +92,8 @@ const useWallpaper = (
|
|||
vantaWaves(config)(desktopRef.current);
|
||||
} else if (wallpaperImage === "HEXELLS") {
|
||||
hexells(desktopRef.current);
|
||||
} else if (wallpaperImage === "COASTAL_LANDSCAPE") {
|
||||
coastalLandscape(desktopRef.current);
|
||||
} else {
|
||||
setWallpaper("VANTA");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,6 +106,11 @@ const useFolderContextMenu = (
|
|||
label: "APOD",
|
||||
toggle: wallpaperImage.startsWith("APOD"),
|
||||
},
|
||||
{
|
||||
action: () => setWallpaper("COASTAL_LANDSCAPE"),
|
||||
label: "Coastal Landscape",
|
||||
toggle: wallpaperImage === "COASTAL_LANDSCAPE",
|
||||
},
|
||||
{
|
||||
action: () => setWallpaper("HEXELLS"),
|
||||
label: "Hexells",
|
||||
|
|
|
|||
3793
public/System/ShaderToy/CoastalLandscape/effect.js
Normal file
3793
public/System/ShaderToy/CoastalLandscape/effect.js
Normal file
File diff suppressed because it is too large
Load Diff
244
public/System/ShaderToy/CoastalLandscape/init.js
Normal file
244
public/System/ShaderToy/CoastalLandscape/init.js
Normal file
File diff suppressed because one or more lines are too long
2934
public/System/ShaderToy/CoastalLandscape/piLibs.js
Normal file
2934
public/System/ShaderToy/CoastalLandscape/piLibs.js
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user