chore: setup linting

This commit is contained in:
Max Richter
2026-02-02 16:22:14 +01:00
parent 137425b31b
commit 30e897468a
174 changed files with 6043 additions and 5107 deletions

View File

@@ -1,23 +1,18 @@
<script lang="ts">
import { T, useTask, useThrelte } from "@threlte/core";
import { colors } from '$lib/graph-interface/graph/colors.svelte';
import { T, useTask, useThrelte } from '@threlte/core';
import { Grid, MeshLineGeometry, MeshLineMaterial, Text } from '@threlte/extras';
import {
Grid,
MeshLineGeometry,
MeshLineMaterial,
Text,
} from "@threlte/extras";
import {
type Group,
type BufferGeometry,
Vector3,
type Vector3Tuple,
Box3,
type BufferGeometry,
type Group,
Mesh,
MeshBasicMaterial,
} from "three";
import { appSettings } from "../settings/app-settings.svelte";
import Camera from "./Camera.svelte";
import { colors } from "$lib/graph-interface/graph/colors.svelte";
Vector3,
type Vector3Tuple
} from 'three';
import { appSettings } from '../settings/app-settings.svelte';
import Camera from './Camera.svelte';
const { renderStage, invalidate: _invalidate } = useThrelte();
@@ -32,7 +27,7 @@
lines,
centerCamera,
fps = $bindable(),
scene = $bindable(),
scene = $bindable()
}: Props = $props();
let geometries = $state.raw<BufferGeometry[]>([]);
@@ -43,13 +38,13 @@
fps.push(1 / delta);
fps = fps.slice(-100);
},
{ stage: renderStage, autoInvalidate: false },
{ stage: renderStage, autoInvalidate: false }
);
export const invalidate = function () {
export const invalidate = function() {
if (scene) {
const geos: BufferGeometry[] = [];
scene.traverse(function (child) {
scene.traverse(function(child) {
if (isMesh(child)) {
geos.push(child.geometry);
}
@@ -67,17 +62,29 @@
_invalidate();
};
function isMesh(child: Mesh | any): child is Mesh {
return child.isObject3D && "material" in child;
function isMesh(child: unknown): child is Mesh {
return (
child !== null
&& typeof child === 'object'
&& 'isObject3D' in child
&& child.isObject3D === true
&& 'material' in child
);
}
function isMatCapMaterial(material: any): material is MeshBasicMaterial {
return material.isMaterial && "matcap" in material;
function isMatCapMaterial(material: unknown): material is MeshBasicMaterial {
return (
material !== null
&& typeof material === 'object'
&& 'isMaterial' in material
&& material.isMaterial === true
&& 'matcap' in material
);
}
$effect(() => {
const wireframe = appSettings.value.debug.wireframe;
scene.traverse(function (child) {
scene.traverse(function(child) {
if (isMesh(child) && isMatCapMaterial(child.material) && child.visible) {
child.material.wireframe = wireframe;
}
@@ -89,7 +96,7 @@
return [
geo.attributes.position.array[i],
geo.attributes.position.array[i + 1],
geo.attributes.position.array[i + 2],
geo.attributes.position.array[i + 2]
] as Vector3Tuple;
}
</script>
@@ -98,12 +105,12 @@
{#if appSettings.value.showGrid}
<Grid
cellColor={colors["outline"]}
cellColor={colors['outline']}
cellThickness={0.7}
infiniteGrid
sectionThickness={0.7}
sectionDistance={2}
sectionColor={colors["outline"]}
sectionColor={colors['outline']}
fadeDistance={50}
fadeStrength={10}
fadeOrigin={new Vector3(0, 0, 0)}
@@ -112,9 +119,9 @@
<T.Group>
{#if geometries}
{#each geometries as geo}
{#each geometries as geo (geo.id)}
{#if appSettings.value.debug.showIndices}
{#each geo.attributes.position.array as _, i}
{#each geo.attributes.position.array, i (i)}
{#if i % 3 === 0}
<Text fontSize={0.25} position={getPosition(geo, i)} />
{/if}
@@ -134,7 +141,7 @@
</T.Group>
{#if appSettings.value.debug.showStemLines && lines}
{#each lines as line}
{#each lines as line (line[0].x + '-' + line[0].y + '-' + '' + line[0].z)}
<T.Mesh>
<MeshLineGeometry points={line} />
<MeshLineMaterial width={0.1} color="red" depthTest={false} />