From 89d05df8b96f1b75c1f83100ad060e2b2902c822 Mon Sep 17 00:00:00 2001 From: "Shane (Sosho) Chang" Date: Sat, 4 May 2024 17:55:37 -0500 Subject: [PATCH] Replace Gizmo with CubeGizmo (#9) * Gizmo replaced with CubeGizmo (custom copy of Gizmo) * update axis colors, reduce font size, add font color, remove circle, remove opacity change * add gray cube, position x y z axis and text * CubeGizmo - fix axis label text getting cut off in certain positions * CubeGizmo - hide axis text when axis is orthogonal to view * CubeGizmo add Front, Right etc text, and orient * CubeGizmo - orient camera when faces are clicked * CubeGizmo - add triangle controls, and rotate when triangle controls are clicked * CubeGizmo - fix triangle up down, accidentally deleted line * CubeGizmo - remove unused code from original Gizmo * run formatter, rename *.d.ts files to *.ts remove unused CubeGizmoEvents and CubeGizmoSlots from .ts file --- .../(CADmium)/CubeGizmo/CubeGizmo.svelte | 459 ++++++++++++++++++ .../(CADmium)/CubeGizmo/CubeGizmo.svelte.ts | 8 + .../routes/(CADmium)/CubeGizmo/CubeGizmo.ts | 25 + .../web/src/routes/(CADmium)/Scene.svelte | 5 +- 4 files changed, 495 insertions(+), 2 deletions(-) create mode 100644 applications/web/src/routes/(CADmium)/CubeGizmo/CubeGizmo.svelte create mode 100644 applications/web/src/routes/(CADmium)/CubeGizmo/CubeGizmo.svelte.ts create mode 100644 applications/web/src/routes/(CADmium)/CubeGizmo/CubeGizmo.ts diff --git a/applications/web/src/routes/(CADmium)/CubeGizmo/CubeGizmo.svelte b/applications/web/src/routes/(CADmium)/CubeGizmo/CubeGizmo.svelte new file mode 100644 index 00000000..39e65010 --- /dev/null +++ b/applications/web/src/routes/(CADmium)/CubeGizmo/CubeGizmo.svelte @@ -0,0 +1,459 @@ + + + + + + + { + if (Array.isArray(parent.material)) parent.material = [...parent.material, self] + else parent.material = [self] + }} + /> + { + if (Array.isArray(parent.material)) parent.material = [...parent.material, self] + else parent.material = [self] + }} + /> + { + if (Array.isArray(parent.material)) parent.material = [...parent.material, self] + else parent.material = [self] + }} + /> + { + if (Array.isArray(parent.material)) parent.material = [...parent.material, self] + else parent.material = [self] + }} + /> + { + if (Array.isArray(parent.material)) parent.material = [...parent.material, self] + else parent.material = [self] + }} + /> + { + if (Array.isArray(parent.material)) parent.material = [...parent.material, self] + else parent.material = [self] + }} + /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/applications/web/src/routes/(CADmium)/CubeGizmo/CubeGizmo.svelte.ts b/applications/web/src/routes/(CADmium)/CubeGizmo/CubeGizmo.svelte.ts new file mode 100644 index 00000000..c5445076 --- /dev/null +++ b/applications/web/src/routes/(CADmium)/CubeGizmo/CubeGizmo.svelte.ts @@ -0,0 +1,8 @@ +import { SvelteComponent } from "svelte" +import type { CubeGizmoProps } from "./CubeGizmo" +declare const __propDef: { + props: CubeGizmoProps +} +type CubeGizmoProps_ = typeof __propDef.props +export { CubeGizmoProps_ as CubeGizmoProps } +export default class CubeGizmo extends SvelteComponent {} diff --git a/applications/web/src/routes/(CADmium)/CubeGizmo/CubeGizmo.ts b/applications/web/src/routes/(CADmium)/CubeGizmo/CubeGizmo.ts new file mode 100644 index 00000000..99ccac5e --- /dev/null +++ b/applications/web/src/routes/(CADmium)/CubeGizmo/CubeGizmo.ts @@ -0,0 +1,25 @@ +import type { Key, ThrelteUseTaskOptions } from "@threlte/core" +import { SvelteComponent } from "svelte" +import type { ColorRepresentation } from "three" +import type { SetCameraFocus } from "shared/types" + +type TaskOptions = Pick & { key?: Key } + +export type CubeGizmoProps = { + renderTask?: TaskOptions + animationTask?: TaskOptions + turnRate?: number + center?: [number, number, number] + verticalPlacement?: "top" | "bottom" + horizontalPlacement?: "left" | "right" + size?: number + xColor?: ColorRepresentation + yColor?: ColorRepresentation + zColor?: ColorRepresentation + toneMapped?: boolean + paddingX?: number + paddingY?: number + setCameraFocus: SetCameraFocus +} + +export default class CubeGizmo extends SvelteComponent {} diff --git a/applications/web/src/routes/(CADmium)/Scene.svelte b/applications/web/src/routes/(CADmium)/Scene.svelte index 28630b36..7a5a9a35 100644 --- a/applications/web/src/routes/(CADmium)/Scene.svelte +++ b/applications/web/src/routes/(CADmium)/Scene.svelte @@ -1,6 +1,6 @@