diff --git a/.changeset/component-tweaks-for-gizmo-mode.md b/.changeset/component-tweaks-for-gizmo-mode.md new file mode 100644 index 000000000..aa98d8089 --- /dev/null +++ b/.changeset/component-tweaks-for-gizmo-mode.md @@ -0,0 +1,5 @@ +--- +'@viamrobotics/motion-tools': patch +--- + +Default `Line` and `Mesh` opacity to `1`, fix `LineDots` instance ID tracking, enable BVH raycasting in `'gizmo'` interaction mode, fix stale matrix reads in `SelectedTransformControls`, and add `isOpen` / `close` to `Popover` snippets plus a `shapes` icon and `disableTooltip` prop on dashboard `Button` diff --git a/src/lib/components/Entities/LineDots.svelte b/src/lib/components/Entities/LineDots.svelte index 569a31358..905b84b14 100644 --- a/src/lib/components/Entities/LineDots.svelte +++ b/src/lib/components/Entities/LineDots.svelte @@ -41,9 +41,15 @@ $effect(() => { if (!positions) return + // Track the IDs `addInstance` returns rather than assuming they're a + // sequential 0..N-1 range — when positions changes (e.g. a line gizmo + // being placed), cleanup-by-index would target slots that were never + // allocated for this effect run and throw "Invalid instanceId". + const instances: number[] = [] for (let i = 0, l = positions.length; i < l; i += 3) { const dotIndex = i / 3 const instance = mesh.addInstance(geometryID) + instances.push(instance) matrix.makeTranslation(positions[i + 0], positions[i + 1], positions[i + 2]) matrix.scale(vec3.setScalar(scale)) mesh.setMatrixAt(instance, matrix) @@ -55,9 +61,8 @@ } return () => { - if (!positions) return - for (let i = 0, l = positions.length / 3; i < l; i += 1) { - mesh.deleteInstance(i) + for (const instance of instances) { + mesh.deleteInstance(instance) } } }) diff --git a/src/lib/components/Scene.svelte b/src/lib/components/Scene.svelte index 5634d8482..140cb7f3f 100644 --- a/src/lib/components/Scene.svelte +++ b/src/lib/components/Scene.svelte @@ -49,7 +49,8 @@ const bvhEnabled = $derived( settings.current.renderSubEntityHoverDetail || settings.current.interactionMode === 'measure' || - settings.current.interactionMode === 'select' + settings.current.interactionMode === 'select' || + settings.current.interactionMode === 'gizmo' ) bvh(raycaster, () => ({ helper: false, enabled: bvhEnabled })) diff --git a/src/lib/components/SelectedTransformControls.svelte b/src/lib/components/SelectedTransformControls.svelte index adc5086b0..b2ca69508 100644 --- a/src/lib/components/SelectedTransformControls.svelte +++ b/src/lib/components/SelectedTransformControls.svelte @@ -1,7 +1,7 @@ -{#if ref && entity && activeMode && !isFragmentComponentWithVariables && !invisible.current} +{#if transforming} {#key entity} - children: Snippet + trigger: Snippet<[HTMLButtonAttributes, { isOpen: boolean }]> + children: Snippet<[{ close: () => void }]> } let { children, trigger }: Props = $props() @@ -15,15 +15,17 @@ const id = $props.id() const service = useMachine(popover.machine, { id }) const api = $derived(popover.connect(service, normalizeProps)) + + const close = () => api.setOpen(false) -{@render trigger(api.getTriggerProps())} +{@render trigger(api.getTriggerProps(), { isOpen: api.open })}
- {@render children()} + {@render children({ close })}
diff --git a/src/lib/components/overlay/dashboard/Button.svelte b/src/lib/components/overlay/dashboard/Button.svelte index c7c7d5d18..b7b27eb18 100644 --- a/src/lib/components/overlay/dashboard/Button.svelte +++ b/src/lib/components/overlay/dashboard/Button.svelte @@ -2,15 +2,16 @@ import type { ClassValue, HTMLButtonAttributes, MouseEventHandler } from 'svelte/elements' import { Icon, type IconName, Tooltip } from '@viamrobotics/prime-core' - import { Focus, MousePointer2, Ruler } from 'lucide-svelte' + import { Focus, MousePointer2, Ruler, Shapes } from 'lucide-svelte' interface Props extends HTMLButtonAttributes { - icon: IconName | 'ruler' | 'mouse-pointer' | 'focus' + icon: IconName | 'ruler' | 'mouse-pointer' | 'shapes' | 'focus' active?: boolean description: string hotkey?: string class?: ClassValue | null | undefined tooltipLocation?: 'bottom' | 'right' | 'left' | 'top' + disableTooltip?: boolean onclick?: MouseEventHandler | null | undefined } @@ -21,6 +22,7 @@ hotkey = '', class: className = '', tooltipLocation, + disableTooltip = false, onclick, ...rest }: Props = $props() @@ -29,6 +31,7 @@