Remove 3D background and guard WebGL usage
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
z-index: -1;
|
z-index: -1;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
|
background-color: var(--scene-bg);
|
||||||
}
|
}
|
||||||
|
|
||||||
.scene-container :global(canvas) {
|
.scene-container :global(canvas) {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { onMount } from 'svelte';
|
||||||
import { Canvas } from '@threlte/core';
|
import { Canvas } from '@threlte/core';
|
||||||
import { T } from '@threlte/core';
|
import { T } from '@threlte/core';
|
||||||
import ParticleField from './ParticleField.svelte';
|
import ParticleField from './ParticleField.svelte';
|
||||||
@@ -8,9 +9,29 @@
|
|||||||
// Reactive theme colors
|
// Reactive theme colors
|
||||||
const bgColor = $derived($themeColors.background);
|
const bgColor = $derived($themeColors.background);
|
||||||
const primaryColor = $derived($themeColors.primary);
|
const primaryColor = $derived($themeColors.primary);
|
||||||
|
|
||||||
|
let webglAvailable = $state(false);
|
||||||
|
|
||||||
|
function isWebGLAvailable() {
|
||||||
|
try {
|
||||||
|
const testCanvas = document.createElement('canvas');
|
||||||
|
const context =
|
||||||
|
testCanvas.getContext('webgl2') ||
|
||||||
|
testCanvas.getContext('webgl') ||
|
||||||
|
testCanvas.getContext('experimental-webgl');
|
||||||
|
return !!(window.WebGLRenderingContext && context);
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
webglAvailable = isWebGLAvailable();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="scene-container">
|
<div class="scene-container" style="--scene-bg: {bgColor};">
|
||||||
|
{#if webglAvailable}
|
||||||
<Canvas>
|
<Canvas>
|
||||||
<T.PerspectiveCamera
|
<T.PerspectiveCamera
|
||||||
makeDefault
|
makeDefault
|
||||||
@@ -36,4 +57,5 @@
|
|||||||
<!-- Background color -->
|
<!-- Background color -->
|
||||||
<T.Color args={[bgColor]} attach="background" />
|
<T.Color args={[bgColor]} attach="background" />
|
||||||
</Canvas>
|
</Canvas>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -385,8 +385,15 @@
|
|||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
if (container) {
|
if (container) {
|
||||||
|
try {
|
||||||
initScene();
|
initScene();
|
||||||
animate();
|
animate();
|
||||||
|
} catch (err) {
|
||||||
|
console.error("WebGL unavailable:", err);
|
||||||
|
loadError = "3D viewer unavailable (WebGL not supported)";
|
||||||
|
isLoading = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
window.addEventListener("resize", handleResize);
|
window.addEventListener("resize", handleResize);
|
||||||
window.addEventListener("keydown", handleKeydown);
|
window.addEventListener("keydown", handleKeydown);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import './layout.css';
|
import './layout.css';
|
||||||
import Background3D from '$lib/components/Background3D.svelte';
|
|
||||||
import { themeColors, mode, colorTheme, toggleMode, setColorTheme, themeOptions } from '$lib/stores/theme';
|
import { themeColors, mode, colorTheme, toggleMode, setColorTheme, themeOptions } from '$lib/stores/theme';
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
import { navigation } from '$lib/config';
|
import { navigation } from '$lib/config';
|
||||||
@@ -76,7 +75,6 @@
|
|||||||
<NavbarWaybar />
|
<NavbarWaybar />
|
||||||
<!-- <Navbar /> -->
|
<!-- <Navbar /> -->
|
||||||
<main class="main-content">
|
<main class="main-content">
|
||||||
<Background3D />
|
|
||||||
{@render children()}
|
{@render children()}
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user