Skip to content

Commit

Permalink
Refactor Canvas2D and CanvasD3 components
Browse files Browse the repository at this point in the history
  • Loading branch information
yustarandomname committed Sep 27, 2024
1 parent cabb990 commit d5c82fb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
4 changes: 1 addition & 3 deletions src/lib/d3/Canvas2D.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
import type { SceneProps } from '$lib/components/Scene.svelte';
import Scene from '$lib/components/Scene.svelte';
import { activityState } from '$lib/stores/activity.svelte';
import { globalState } from '$lib/stores/globalState.svelte';
import type { Camera3DProps } from '$lib/threlte/Camera3D.svelte';
import Camera3D from '$lib/threlte/Camera3D.svelte';
import CustomRenderer from '$lib/threlte/CustomRenderer.svelte';
import { hasProps } from '$lib/utils/hasProps';
import { parseUrl } from '$lib/utils/parseUrl';
import { Canvas } from '@threlte/core';
import { type Snippet } from 'svelte';
Expand All @@ -19,7 +17,7 @@
type CanvasProps = SceneProps &
Omit<Canvas2DProps, 'children' | 'width'> & {
title?: string;
splitCanvas2DProps?: Omit<Canvas2DProps, 'children' | 'width'>;
splitCanvas2DProps?: Omit<Canvas2DProps, 'children' | 'width' | 'height' | 'isSplit'>;
splitCanvas3DProps?: Camera3DProps; // Not implemented yet
children: Snippet;
splitCanvas2DChildren?: Snippet;
Expand Down
8 changes: 4 additions & 4 deletions src/lib/d3/CanvasD3.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
cameraZoom?: number;
tickLength?: number; // TODO: move axis to separate component
showAxisNumbers?: boolean;
width: number;
height: number;
width?: number;
height?: number;
enablePan?: boolean;
draggables?: Draggable[];
isSplit?: boolean;
Expand Down Expand Up @@ -42,8 +42,8 @@
cameraZoom = 1,
tickLength,
showAxisNumbers,
width,
height,
width = 500,
height = 300,
enablePan = true,
draggables = [],
isSplit = false,
Expand Down
8 changes: 3 additions & 5 deletions src/lib/threlte/Canvas3D.svelte
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
<script lang="ts">
import { page } from '$app/stores';
import Confetti from '$lib/components/Confetti.svelte';
import Konami from '$lib/components/Konami.svelte';
import type { SceneProps } from '$lib/components/Scene.svelte';
import Scene from '$lib/components/Scene.svelte';
import type { Canvas2DProps } from '$lib/d3/CanvasD3.svelte';
import CanvasD3 from '$lib/d3/CanvasD3.svelte';
import { activityState } from '$lib/stores/activity.svelte';
import { globalState } from '$lib/stores/globalState.svelte';
import { confettiState } from '$lib/stores/confetti.svelte';
import { parseUrl } from '$lib/utils/parseUrl';
import { hasProps } from '$lib/utils/hasProps';
import { Canvas } from '@threlte/core';
import type { Snippet } from 'svelte';
import { NoToneMapping, Vector3 } from 'three';
import Camera3D, { type Camera3DProps } from './Camera3D.svelte';
import CustomRenderer from './CustomRenderer.svelte';
import Confetti from '$lib/components/Confetti.svelte';
import { confettiState } from '$lib/stores/confetti.svelte';
type CanvasProps = SceneProps &
Omit<Camera3DProps, 'children' | 'width'> & {
title?: string;
splitCanvas2DProps?: Omit<Canvas2DProps, 'children' | 'width' | 'isSplit'>;
splitCanvas2DProps?: Omit<Canvas2DProps, 'children' | 'width' | 'height' | 'isSplit'>;
splitCanvas3DProps?: Omit<Camera3DProps, 'isSplit'>;
children: Snippet;
splitCanvas2DChildren?: Snippet;
Expand Down

0 comments on commit d5c82fb

Please sign in to comment.